Remove invalid code

This commit is contained in:
SWHL committed 2023-10-21 17:00:23 +08:00
1 parent 6d3c7ab0e1
commit cc96a2b00c
11 files changed
+124 -87

No files matched your search

+4 -1
View File
@@ -3,7 +3,10 @@
# @Contact: liekkaskono@163.com
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, VisRes
-1
View File
@@ -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")
+1 -1
View File
@@ -5,4 +5,4 @@ numpy>=1.19.5
six>=1.15.0
Shapely>=1.7.1
PyYAML
Pillow
Pillow<=9.5.0
+1 -1
View File
@@ -5,4 +5,4 @@ numpy>=1.19.5
six>=1.15.0
Shapely>=1.7.1
PyYAML
Pillow
Pillow<=9.5.0
-28
View File
@@ -1,28 +0,0 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: liekkaskono@163.com
import cv2
import pytest
from base_module import BaseModule
@pytest.mark.parametrize(
"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"
-25
View File
@@ -1,25 +0,0 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: liekkaskono@163.com
import cv2
import pytest
from base_module import BaseModule
@pytest.mark.parametrize("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)
@@ -7,6 +7,7 @@ from pathlib import Path
import cv2
import numpy as np
import pytest
from base_module import BaseModule
root_dir = Path(__file__).resolve().parent.parent
sys.path.append(str(root_dir))
@@ -16,6 +17,7 @@ from rapidocr_onnxruntime import LoadImageError, RapidOCR
engine = 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] == "韩国小馆"
-26
View File
@@ -1,26 +0,0 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: liekkaskono@163.com
import cv2
import pytest
from base_module import BaseModule
@pytest.mark.parametrize("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] == "韩国小馆"
@@ -7,6 +7,7 @@ from pathlib import Path
import cv2
import numpy as np
import pytest
from base_module import BaseModule
root_dir = Path(__file__).resolve().parent.parent
sys.path.append(str(root_dir))
@@ -16,6 +17,7 @@ from rapidocr_openvino import LoadImageError, RapidOCR
engine = 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] == "韩国小馆"