argument.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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, workers=5
  23. )
  24. self.__update(**kwargs)
  25. def __update(self, **kwargs):
  26. for k, v in kwargs.items():
  27. self.__dict__[k] = v
  28. def __getattr__(self, key: "str"):
  29. return self.__dict__[key]
  30. def __setattr__(self, key: "str", value):
  31. self.__dict__[key] = value
  32. ArgType = Args