π Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
Remove invalid code
SWHLcc96a2b00cbc
diff --git a/.github/workflows/gen_whl_to_pypi_rapidocr_ort.yml b/.github/workflows/gen_whl_to_pypi_rapidocr_ort.ymlindex 5ca4f68..8578bb6 100644--- a/.github/workflows/gen_whl_to_pypi_rapidocr_ort.yml+++ b/.github/workflows/gen_whl_to_pypi_rapidocr_ort.yml@@ -38,14 +38,13 @@ jobs:DIR_NAME=${ZIP_NAME%.*}unzip $DIR_NAMEcp $DIR_NAME/resources/models/*.onnx python/rapidocr_onnxruntime/models/- cp $DIR_NAME/resources/models/*.onnx python/rapidocr_openvino/models/cd pythonpip install -r requirements_ort.txtpip install pytest wheel get_pypi_latest_version openvinocd testswget $TWO_DIM_IMAGE -O two_dim_image.npymv two_dim_image.npy test_files/- pytest test_det.py test_cls.py test_rec.py test_all_ort.py+ pytest test_ort.pyGenerateWHL_PushPyPi:needs: UnitTestingdiff --git a/.github/workflows/gen_whl_to_pypi_rapidocr_vino.yml b/.github/workflows/gen_whl_to_pypi_rapidocr_vino.ymlindex 5dec3d8..dff426a 100644--- a/.github/workflows/gen_whl_to_pypi_rapidocr_vino.yml+++ b/.github/workflows/gen_whl_to_pypi_rapidocr_vino.yml@@ -37,7 +37,6 @@ jobs:ZIP_NAME=${RESOURCES_URL##*/}DIR_NAME=${ZIP_NAME%.*}unzip $DIR_NAME- cp $DIR_NAME/resources/models/*.onnx python/rapidocr_onnxruntime/models/cp $DIR_NAME/resources/models/*.onnx python/rapidocr_openvino/models/cd pythonpip install -r requirements_vino.txt@@ -45,7 +44,7 @@ jobs:cd testswget $TWO_DIM_IMAGE -O two_dim_image.npymv two_dim_image.npy test_files/- pytest test_det.py test_cls.py test_rec.py test_all_vino.py+ pytest test_vino.pyGenerateWHL_PushPyPi:needs: UnitTestingdiff --git a/python/demo.py b/python/demo.pyindex 0792344..c191379 100644--- a/python/demo.py+++ b/python/demo.py@@ -3,7 +3,10 @@# @Contact: [email protected]import cv2-from rapidocr_onnxruntime import RapidOCR, VisRes+from rapidocr_paddle import RapidOCR, VisRes++# from rapidocr_onnxruntime import RapidOCR, VisRes+# from rapidocr_openvino import RapidOCR, VisResdiff --git a/python/rapidocr_openvino/utils.py b/python/rapidocr_openvino/utils.pyindex 0131397..f391045 100644--- a/python/rapidocr_openvino/utils.py+++ b/python/rapidocr_openvino/utils.py@@ -22,7 +22,6 @@ class OpenVINOInferSession:def __init__(self, config):ie = Core()- config["model_path"] = str(root_dir / config["model_path"])self._verify_model(config["model_path"])model_onnx = ie.read_model(config["model_path"])compile_model = ie.compile_model(model=model_onnx, device_name="CPU")diff --git a/python/requirements_ort.txt b/python/requirements_ort.txtindex 4111d1f..11e93fc 100644--- a/python/requirements_ort.txt+++ b/python/requirements_ort.txt@@ -5,4 +5,4 @@ numpy>=1.19.5six>=1.15.0Shapely>=1.7.1PyYAML-Pillow+Pillow<=9.5.0diff --git a/python/requirements_vino.txt b/python/requirements_vino.txtindex 881bbd3..d6255f4 100644--- a/python/requirements_vino.txt+++ b/python/requirements_vino.txt@@ -5,4 +5,4 @@ numpy>=1.19.5six>=1.15.0Shapely>=1.7.1PyYAML-Pillow\ No newline at end of file+Pillow<=9.5.0\ No newline at end of filediff --git a/python/tests/test_cls.py b/python/tests/test_cls.pydeleted file mode 100644index a5ebd04..0000000--- a/python/tests/test_cls.py+++ /dev/null@@ -1,28 +0,0 @@-# -*- encoding: utf-8 -*--# @Author: SWHL-# @Contact: [email protected]-import cv2-import pytest-from base_module import BaseModule--- "package_name", [("rapidocr_onnxruntime"), ("rapidocr_openvino")]-)-def test_cls(package_name: str):- module_name = "ch_ppocr_v2_cls"- class_name = "TextClassifier"-- base = BaseModule(package_name=package_name)- TextClassifier = base.init_module(module_name, class_name)-- yaml_path = base.package_dir / module_name / "config.yaml"- config = base.read_yaml(str(yaml_path))- config["model_path"] = str(base.package_dir / config["model_path"])-- text_cls = TextClassifier(config)-- img_path = base.tests_dir / "test_files" / "text_cls.jpg"- img = cv2.imread(str(img_path))- result = text_cls([img])- assert result[1][0][0] == "180"diff --git a/python/tests/test_det.py b/python/tests/test_det.pydeleted file mode 100644index d7bd057..0000000--- a/python/tests/test_det.py+++ /dev/null@@ -1,25 +0,0 @@-# -*- encoding: utf-8 -*--# @Author: SWHL-# @Contact: [email protected]-import cv2-import pytest-from base_module import BaseModule--[email protected]("package_name", ["rapidocr_onnxruntime", "rapidocr_openvino"])-def test_det(package_name):- module_name = "ch_ppocr_v3_det"- class_name = "TextDetector"-- base = BaseModule(package_name)- TextDetector = base.init_module(module_name, class_name)-- yaml_path = base.package_dir / module_name / "config.yaml"- config = base.read_yaml(str(yaml_path))- config["model_path"] = str(base.package_dir / config["model_path"])-- text_det = TextDetector(config)- img_path = base.tests_dir / "test_files" / "text_det.jpg"- img = cv2.imread(str(img_path))- dt_boxes, elapse = text_det(img)- assert dt_boxes.shape == (18, 4, 2)diff --git a/python/tests/test_all_ort.py b/python/tests/test_ort.pysimilarity index 67%rename from python/tests/test_all_ort.pyrename to python/tests/test_ort.pyindex 5b6ce74..86f48a3 100644--- a/python/tests/test_all_ort.py+++ b/python/tests/test_ort.py@@ -7,6 +7,7 @@ from pathlib import Pathimport cv2import numpy as npimport pytest+from base_module import BaseModuleroot_dir = Path(__file__).resolve().parent.parentsys.path.append(str(root_dir))@@ -16,6 +17,7 @@ from rapidocr_onnxruntime import LoadImageError, RapidOCRengine = RapidOCR()tests_dir = root_dir / "tests" / "test_files"img_path = tests_dir / "ch_en_num.jpg"+package_name = "rapidocr_onnxruntime"def test_only_det():@@ -145,3 +147,59 @@ def test_input_three_ndim_one_channel():assert result[0][1] == "ζ£εδΏι"assert len(result) == 16+++def test_det():+ module_name = "ch_ppocr_v3_det"+ class_name = "TextDetector"++ base = BaseModule(package_name)+ TextDetector = base.init_module(module_name, class_name)++ yaml_path = base.package_dir / module_name / "config.yaml"+ config = base.read_yaml(str(yaml_path))+ config["model_path"] = str(base.package_dir / config["model_path"])++ text_det = TextDetector(config)+ img_path = base.tests_dir / "test_files" / "text_det.jpg"+ img = cv2.imread(str(img_path))+ dt_boxes, elapse = text_det(img)+ assert dt_boxes.shape == (18, 4, 2)+++def test_cls():+ module_name = "ch_ppocr_v2_cls"+ class_name = "TextClassifier"++ base = BaseModule(package_name=package_name)+ TextClassifier = base.init_module(module_name, class_name)++ yaml_path = base.package_dir / module_name / "config.yaml"+ config = base.read_yaml(str(yaml_path))+ config["model_path"] = str(base.package_dir / config["model_path"])++ text_cls = TextClassifier(config)++ img_path = base.tests_dir / "test_files" / "text_cls.jpg"+ img = cv2.imread(str(img_path))+ result = text_cls([img])+ assert result[1][0][0] == "180"+++def test_rec():+ module_name = "ch_ppocr_v3_rec"+ class_name = "TextRecognizer"++ base = BaseModule(package_name)+ TextRecognizer = base.init_module(module_name, class_name)++ yaml_path = base.package_dir / module_name / "config.yaml"+ config = base.read_yaml(str(yaml_path))+ config["model_path"] = str(base.package_dir / config["model_path"])++ text_rec = TextRecognizer(config)++ img_path = base.tests_dir / "test_files" / "text_rec.jpg"+ img = cv2.imread(str(img_path))+ rec_res, elapse = text_rec(img)+ assert rec_res[0][0] == "ι©ε½ε°ι¦"diff --git a/python/tests/test_rec.py b/python/tests/test_rec.pydeleted file mode 100644index ac94289..0000000--- a/python/tests/test_rec.py+++ /dev/null@@ -1,26 +0,0 @@-# -*- encoding: utf-8 -*--# @Author: SWHL-# @Contact: [email protected]-import cv2-import pytest-from base_module import BaseModule--[email protected]("package_name", ["rapidocr_onnxruntime", "rapidocr_openvino"])-def test_det(package_name):- module_name = "ch_ppocr_v3_rec"- class_name = "TextRecognizer"-- base = BaseModule(package_name)- TextRecognizer = base.init_module(module_name, class_name)-- yaml_path = base.package_dir / module_name / "config.yaml"- config = base.read_yaml(str(yaml_path))- config["model_path"] = str(base.package_dir / config["model_path"])-- text_rec = TextRecognizer(config)-- img_path = base.tests_dir / "test_files" / "text_rec.jpg"- img = cv2.imread(str(img_path))- rec_res, elapse = text_rec(img)- assert rec_res[0][0] == "ι©ε½ε°ι¦"diff --git a/python/tests/test_all_vino.py b/python/tests/test_vino.pysimilarity index 67%rename from python/tests/test_all_vino.pyrename to python/tests/test_vino.pyindex 612fe05..44528f1 100644--- a/python/tests/test_all_vino.py+++ b/python/tests/test_vino.py@@ -7,6 +7,7 @@ from pathlib import Pathimport cv2import numpy as npimport pytest+from base_module import BaseModuleroot_dir = Path(__file__).resolve().parent.parentsys.path.append(str(root_dir))@@ -16,6 +17,7 @@ from rapidocr_openvino import LoadImageError, RapidOCRengine = RapidOCR()tests_dir = root_dir / "tests" / "test_files"img_path = tests_dir / "ch_en_num.jpg"+package_name = "rapidocr_openvino"def test_only_det():@@ -145,3 +147,59 @@ def test_input_three_ndim_one_channel():assert result[0][1] == "ζ£εδΏι"assert len(result) == 16+++def test_det():+ module_name = "ch_ppocr_v3_det"+ class_name = "TextDetector"++ base = BaseModule(package_name)+ TextDetector = base.init_module(module_name, class_name)++ yaml_path = base.package_dir / module_name / "config.yaml"+ config = base.read_yaml(str(yaml_path))+ config["model_path"] = str(base.package_dir / config["model_path"])++ text_det = TextDetector(config)+ img_path = base.tests_dir / "test_files" / "text_det.jpg"+ img = cv2.imread(str(img_path))+ dt_boxes, elapse = text_det(img)+ assert dt_boxes.shape == (18, 4, 2)+++def test_cls():+ module_name = "ch_ppocr_v2_cls"+ class_name = "TextClassifier"++ base = BaseModule(package_name=package_name)+ TextClassifier = base.init_module(module_name, class_name)++ yaml_path = base.package_dir / module_name / "config.yaml"+ config = base.read_yaml(str(yaml_path))+ config["model_path"] = str(base.package_dir / config["model_path"])++ text_cls = TextClassifier(config)++ img_path = base.tests_dir / "test_files" / "text_cls.jpg"+ img = cv2.imread(str(img_path))+ result = text_cls([img])+ assert result[1][0][0] == "180"+++def test_rec():+ module_name = "ch_ppocr_v3_rec"+ class_name = "TextRecognizer"++ base = BaseModule(package_name)+ TextRecognizer = base.init_module(module_name, class_name)++ yaml_path = base.package_dir / module_name / "config.yaml"+ config = base.read_yaml(str(yaml_path))+ config["model_path"] = str(base.package_dir / config["model_path"])++ text_rec = TextRecognizer(config)++ img_path = base.tests_dir / "test_files" / "text_rec.jpg"+ img = cv2.imread(str(img_path))+ rec_res, elapse = text_rec(img)+ assert rec_res[0][0] == "ι©ε½ε°ι¦"