Skip to content

πŸ“„ Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

chore: update demo code

SWHL0ab091c1a0f8
diff --git a/python/demo.py b/python/demo.py
index eae54aa..16506c4 100644
--- a/python/demo.py
+++ b/python/demo.py
@@ -1,21 +1,15 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
-from pathlib import Path
-
+# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
from rapidocr import RapidOCR
-engine = RapidOCR()
-
-# img_url = "https://img1.baidu.com/it/u=3619974146,1266987475&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=516"
-
-# img_paths = ["tmp/en.jpg", "tmp/ch.jpg", "tmp/ch_en.jpg"]
+engine = RapidOCR(params={"Global.with_torch": True})
-# for img_path in img_paths:
-# result = engine(img_path, return_word_box=True)
-# # print(result)
+img_url = "https://img1.baidu.com/it/u=3619974146,1266987475&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=516"
+result = engine(img_url)
+print(result)
-# result.vis(f"tmp/vis_{Path(img_path).stem}.jpg")
-img_path = "tmp/ch.jpg"
-result = engine(img_path, return_word_box=True)
-result.vis(f"tmp/vis_{Path(img_path).stem}.jpg")
+result.vis("vis_result.jpg")