use.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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-09-30 15:08:48
  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/sxkj/Desktop/9.29/1/img')
  14. image_type = 1
  15. # 是否旋转
  16. image_rotate = False
  17. ocr_address = 'DXtest' # 'local' 'TXtest' 'TXsb' 'DXtest' 'DXsb'
  18. ocr_name = 'cet' # 'cet' 'idcard' 'bankcard' 'regbook' 'schoolcert' 'business_license'
  19. md_name = 'CET'
  20. filed = 'cet'
  21. # 若md_path为None 则默认使用图片父路径为markdown保存路径
  22. # md_path = '/Users/zeke/work/sx/OCR/HROCR/to_md/example' or image_path.parent
  23. md_path = None or image_path.parent
  24. md_file = parser_path(Path(md_path) / Path(md_name + image_path.stem), image_rotate)
  25. if __name__ == '__main__':
  26. markdown = MD(md_file)
  27. dataset = Dataset(image_path, image_type, ocr_name, ocr_address, filed, image_rotate)
  28. print(len(dataset))
  29. for d in dataset():
  30. print(d)
  31. dataset.evaluate()
  32. print(dataset.accuracy)
  33. markdown.write_total_accuracy(dataset)
  34. markdown.write_table_accuracy(dataset)
  35. markdown.write_table_result(dataset)
  36. print(md_file)
  37. markdown.f.create_md_file()