use.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from pathlib import Path
  2. import time
  3. from new import MD, Image, Dataset, parser_path
  4. # config
  5. # 图片路径
  6. image_path = Path('/Users/sxkj/Desktop/测试文档/四六级/9.8/身份证/img')
  7. image_type = 1
  8. # 是否旋转
  9. image_rotate = True
  10. ocr_address = 'local' # 'local' 'test' 'sb'
  11. ocr_name = 'regbook' # 'cet' 'idcard' 'bankcard' 'regbook' 'schoolcert'
  12. md_name = 'RegBook'
  13. filed = 'regbook'
  14. # 若md_path为None 则默认使用图片父路径为markdown保存路径
  15. # md_path = '/Users/zeke/work/sx/OCR/HROCR/to_md/example' or image_path.parent
  16. md_path = None or image_path.parent
  17. md_file = parser_path(Path(md_path) / Path(md_name), image_rotate)
  18. if __name__ == '__main__':
  19. markdown = MD(md_file)
  20. dataset = Dataset(image_path, image_type, ocr_name, ocr_address, filed, image_rotate)
  21. print(len(dataset))
  22. for d in dataset():
  23. print(d)
  24. dataset.evaluate()
  25. print(dataset.accuracy)
  26. markdown.write_total_accuracy(dataset)
  27. markdown.write_table_accuracy(dataset)
  28. markdown.write_table_result(dataset)
  29. print(md_file)
  30. markdown.f.create_md_file()