argument.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. __all__ = ["Args", "ArgType"]
  2. class Args:
  3. def __init__(self, **kwargs):
  4. self.__update(
  5. use_gpu=False, precision="fp32", use_tensorrt=False,
  6. # gpu
  7. gpu_mem=500, max_batch_size=6, min_subgraph_size=15,
  8. # cpu
  9. enable_mkldnn=True, cpu_threads=16,
  10. # detector
  11. det_model_dir="hmOCR/static/det", det_algorithm="DB", det_limit_side_len=960,
  12. det_limit_type="max", det_db_thresh=0.3, det_db_box_thresh=0.6, det_db_unclip_ratio=1.5,
  13. det_use_dilation=False, det_db_score_mode="fast", det_box_type="quad",
  14. # classifier
  15. cls_model_dir="hmOCR/static/cls", cls_image_shape="3, 48, 192",
  16. cls_batch_num=6, cls_thresh=0.9, cls_label_list=["0", "180"],
  17. # recognizer
  18. rec_model_dir="hmOCR/static/rec", rec_algorithm="SVTR_LCNet",
  19. rec_image_shape="3, 48, 320", rec_batch_num=8, max_text_length=25,
  20. rec_char_dict_path="hmOCR/static/key-set.txt", use_space_char=False,
  21. # OCR
  22. drop_score=0.5,
  23. # test
  24. image_dir="static/test_image", warmup=True
  25. )
  26. self.__update(**kwargs)
  27. def __update(self, **kwargs):
  28. for k, v in kwargs.items():
  29. self.__dict__[k] = v
  30. def __getattr__(self, key: "str"):
  31. return self.__dict__[key]
  32. def __setattr__(self, key: "str", value):
  33. self.__dict__[key] = value
  34. ArgType = Args