use.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. '''
  2. Author: zeke-chin zeke-chin@icloud.com
  3. Date: 2022-09-28 20:28:41
  4. LastEditors: zeke-chin zeke-chin@icloud.com
  5. LastEditTime: 2022-10-10 21:14:29
  6. FilePath: /to_md/HR_OCR/to_md/use.py
  7. Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. '''
  9. from pathlib import Path
  10. from new import MD, Image, Dataset, parser_path
  11. # config
  12. # 图片路径
  13. image_path = Path('/Users/zeke/Downloads/户口本测试样本1011-常住人口页')
  14. # 是否旋转
  15. image_rotate = False
  16. ocr_address = 'DXtest' # 'local' 'TXtest' 'TXsb' 'DXtest' 'DXsb'
  17. ocr_name = 'regbook' # 'cet' 'idcard' 'bankcard' 'regbook' 'schoolcert' 'business_license'
  18. md_name = 'RBook'
  19. filed = 'regbook'
  20. # 若md_path为None 则默认使用图片父路径为markdown保存路径
  21. # md_path = '/Users/zeke/work/sx/OCR/HROCR/to_md/example' or image_path.parent
  22. md_path = None or image_path.parent
  23. md_file = parser_path(Path(md_path) / Path(md_name + image_path.stem), image_rotate)
  24. if __name__ == '__main__':
  25. markdown = MD(md_file)
  26. dataset = Dataset(image_path, image_type, ocr_name, ocr_address, filed, image_rotate)
  27. print(len(dataset))
  28. for d in dataset():
  29. print(d)
  30. dataset.evaluate()
  31. print(dataset.accuracy)
  32. markdown.write_total_accuracy(dataset)
  33. markdown.write_table_accuracy(dataset)
  34. markdown.write_table_result(dataset)
  35. print(md_file)
  36. markdown.f.create_md_file()