Skip to content

Commit

Permalink
refactor(rapidocr_onnxruntime): Decoupling utils.py files
Browse files Browse the repository at this point in the history
  • Loading branch information
SWHL committed May 18, 2024
1 parent d60fe5b commit de44841
Show file tree
Hide file tree
Showing 8 changed files with 745 additions and 692 deletions.
10 changes: 6 additions & 4 deletions python/rapidocr_onnxruntime/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
LoadImage,
UpdateParameters,
VisRes,
get_logger,
init_args,
read_yaml,
update_model_path,
)

root_dir = Path(__file__).resolve().parent
DEFAULT_CFG_PATH = root_dir / "config.yaml"
logger = get_logger("RapidOCR")


class RapidOCR:
Expand Down Expand Up @@ -246,10 +248,10 @@ def main():
use_cls=use_cls,
use_rec=use_rec,
)
print(result)
logger.info(result)

if args.print_cost:
print(elapse_list)
logger.info(elapse_list)

if args.vis_res:
vis = VisRes()
Expand All @@ -260,7 +262,7 @@ def main():
boxes, *_ = list(zip(*result))
vis_img = vis(args.img_path, boxes)
cv2.imwrite(str(save_path), vis_img)
print(f"The vis result has saved in {save_path}")
logger.info("The vis result has saved in %s", save_path)

elif use_det and use_rec:
font_path = Path(args.vis_font_path)
Expand All @@ -270,7 +272,7 @@ def main():
boxes, txts, scores = list(zip(*result))
vis_img = vis(args.img_path, boxes, txts, scores, font_path=font_path)
cv2.imwrite(str(save_path), vis_img)
print(f"The vis result has saved in {save_path}")
logger.info("The vis result has saved in %s", save_path)


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit de44841

Please sign in to comment.