From 8806af16ada4646084641f6105727a50c7780113 Mon Sep 17 00:00:00 2001 From: SWHL Date: Wed, 20 Sep 2023 15:57:16 +0800 Subject: [PATCH] Fixed issue #124 --- python/rapidocr_onnxruntime/main.py | 5 ++++- python/rapidocr_onnxruntime/utils.py | 18 +++++++++++++----- python/rapidocr_openvino/main.py | 5 ++++- python/rapidocr_openvino/utils.py | 18 +++++++++++++----- python/setup_onnxruntime.py | 1 + python/setup_openvino.py | 1 + 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/python/rapidocr_onnxruntime/main.py b/python/rapidocr_onnxruntime/main.py index e9c98d479..483c4a7db 100644 --- a/python/rapidocr_onnxruntime/main.py +++ b/python/rapidocr_onnxruntime/main.py @@ -250,8 +250,11 @@ def main(): args = init_args() ocr_engine = RapidOCR(**vars(args)) + use_det = not args.no_det + use_cls = not args.no_cls + use_rec = not args.no_rec result, elapse_list = ocr_engine( - args.img_path, use_det=args.use_det, use_cls=args.use_cls, use_rec=args.use_rec + args.img_path, use_det=use_det, use_cls=use_cls, use_rec=use_rec ) print(result) if args.print_cost: diff --git a/python/rapidocr_onnxruntime/utils.py b/python/rapidocr_onnxruntime/utils.py index 4a1d76a9c..481c6c9fa 100644 --- a/python/rapidocr_onnxruntime/utils.py +++ b/python/rapidocr_onnxruntime/utils.py @@ -223,10 +223,12 @@ def init_args(): global_group = parser.add_argument_group(title="Global") global_group.add_argument("--text_score", type=float, default=0.5) - global_group.add_argument("--use_det", type=bool, default=True) - global_group.add_argument("--use_cls", type=bool, default=True) - global_group.add_argument("--use_rec", type=bool, default=True) - global_group.add_argument("--print_verbose", type=bool, default=False) + + global_group.add_argument("--no_det", action="store_true", default=False) + global_group.add_argument("--no_cls", action="store_true", default=False) + global_group.add_argument("--no_rec", action="store_true", default=False) + + global_group.add_argument("--print_verbose", action="store_true", default=False) global_group.add_argument("--min_height", type=int, default=30) global_group.add_argument("--width_height_ratio", type=int, default=8) @@ -240,7 +242,9 @@ def init_args(): det_group.add_argument("--det_thresh", type=float, default=0.3) det_group.add_argument("--det_box_thresh", type=float, default=0.5) det_group.add_argument("--det_unclip_ratio", type=float, default=1.6) - det_group.add_argument("--det_use_dilation", type=bool, default=True) + det_group.add_argument( + "--det_donot_use_dilation", action="store_true", default=False + ) det_group.add_argument( "--det_score_mode", type=str, default="fast", choices=["slow", "fast"] ) @@ -272,6 +276,10 @@ def parse_kwargs(self, **kwargs): for k, v in kwargs.items(): if k.startswith("det"): k = k.split("det_")[1] + if k == "donot_use_dilation": + k = "use_dilation" + v = not v + det_dict[k] = v elif k.startswith("cls"): cls_dict[k] = v diff --git a/python/rapidocr_openvino/main.py b/python/rapidocr_openvino/main.py index e9c98d479..483c4a7db 100644 --- a/python/rapidocr_openvino/main.py +++ b/python/rapidocr_openvino/main.py @@ -250,8 +250,11 @@ def main(): args = init_args() ocr_engine = RapidOCR(**vars(args)) + use_det = not args.no_det + use_cls = not args.no_cls + use_rec = not args.no_rec result, elapse_list = ocr_engine( - args.img_path, use_det=args.use_det, use_cls=args.use_cls, use_rec=args.use_rec + args.img_path, use_det=use_det, use_cls=use_cls, use_rec=use_rec ) print(result) if args.print_cost: diff --git a/python/rapidocr_openvino/utils.py b/python/rapidocr_openvino/utils.py index ad78cdc14..093e48748 100644 --- a/python/rapidocr_openvino/utils.py +++ b/python/rapidocr_openvino/utils.py @@ -155,10 +155,12 @@ def init_args(): global_group = parser.add_argument_group(title="Global") global_group.add_argument("--text_score", type=float, default=0.5) - global_group.add_argument("--use_det", type=bool, default=True) - global_group.add_argument("--use_cls", type=bool, default=True) - global_group.add_argument("--use_rec", type=bool, default=True) - global_group.add_argument("--print_verbose", type=bool, default=False) + + global_group.add_argument("--no_det", action="store_true", default=False) + global_group.add_argument("--no_cls", action="store_true", default=False) + global_group.add_argument("--no_rec", action="store_true", default=False) + + global_group.add_argument("--print_verbose", action="store_true", default=False) global_group.add_argument("--min_height", type=int, default=30) global_group.add_argument("--width_height_ratio", type=int, default=8) @@ -171,7 +173,9 @@ def init_args(): det_group.add_argument("--det_thresh", type=float, default=0.3) det_group.add_argument("--det_box_thresh", type=float, default=0.5) det_group.add_argument("--det_unclip_ratio", type=float, default=1.6) - det_group.add_argument("--det_use_dilation", type=bool, default=True) + det_group.add_argument( + "--det_donot_use_dilation", action="store_true", default=False + ) det_group.add_argument( "--det_score_mode", type=str, default="fast", choices=["slow", "fast"] ) @@ -201,6 +205,10 @@ def parse_kwargs(self, **kwargs): for k, v in kwargs.items(): if k.startswith("det"): k = k.split("det_")[1] + if k == "donot_use_dilation": + k = "use_dilation" + v = not v + det_dict[k] = v elif k.startswith("cls"): cls_dict[k] = v diff --git a/python/setup_onnxruntime.py b/python/setup_onnxruntime.py index 91d5832bb..c16b0eaa9 100644 --- a/python/setup_onnxruntime.py +++ b/python/setup_onnxruntime.py @@ -39,6 +39,7 @@ def get_readme(): project_urls = { "Documentation": "https://rapidai.github.io/RapidOCRDocs/docs/install_usage/rapidocr/rapidocr_onnxruntime/", + "Changelog": "https://rapidai.github.io/RapidOCRDocs/docs/changelog/rapidocr/", } setuptools.setup( diff --git a/python/setup_openvino.py b/python/setup_openvino.py index 107e4accd..8fba83200 100644 --- a/python/setup_openvino.py +++ b/python/setup_openvino.py @@ -39,6 +39,7 @@ def get_readme(): project_urls = { "Documentation": "https://rapidai.github.io/RapidOCRDocs/docs/install_usage/rapidocr/rapidocr_openvino/", + "Changelog": "https://rapidai.github.io/RapidOCRDocs/docs/changelog/rapidocr/", } setuptools.setup(