Skip to content

Commit

Permalink
Fixed issue #124
Browse files Browse the repository at this point in the history
  • Loading branch information
SWHL committed Sep 20, 2023
1 parent e737902 commit 8806af1
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
5 changes: 4 additions & 1 deletion python/rapidocr_onnxruntime/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 13 additions & 5 deletions python/rapidocr_onnxruntime/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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"]
)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion python/rapidocr_openvino/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 13 additions & 5 deletions python/rapidocr_openvino/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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"]
)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions python/setup_onnxruntime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions python/setup_openvino.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8806af1

Please sign in to comment.