use.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from pathlib import Path
  2. from new import MD, Image, Dataset, parser_path
  3. # config
  4. # 图片路径
  5. image_path = Path('/Users/sxkj/Desktop/户口本9.8/img')
  6. image_type = 0
  7. # 是否旋转
  8. image_rotate = False
  9. ocr_address = 'local' # 'local' 'TXtest' 'TXsb''DXtest' 'DXsb'
  10. ocr_name = 'regbook' # 'cet' 'idcard' 'bankcard' 'regbook' 'schoolcert''business_license'
  11. md_name = 'RegBook'
  12. filed = 'regbook'
  13. # 若md_path为None 则默认使用图片父路径为markdown保存路径
  14. # md_path = '/Users/zeke/work/sx/OCR/HROCR/to_md/example' or image_path.parent
  15. md_path = None or image_path.parent
  16. md_file = parser_path(Path(md_path) / Path(md_name + image_path.stem), image_rotate)
  17. if __name__ == '__main__':
  18. markdown = MD(md_file)
  19. dataset = Dataset(image_path, image_type, ocr_name, ocr_address, filed, image_rotate)
  20. print(len(dataset))
  21. for d in dataset():
  22. print(d)
  23. dataset.evaluate()
  24. print(dataset.accuracy)
  25. markdown.write_total_accuracy(dataset)
  26. markdown.write_table_accuracy(dataset)
  27. markdown.write_table_result(dataset)
  28. print(md_file)
  29. markdown.f.create_md_file()