use.py 1.6 KB

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