π Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
test: add cls unit testings
SWHLece967983d02
diff --git a/python/tests/test_cls.py b/python/tests/test_cls.pynew file mode 100644index 0000000..fd95ca4--- /dev/null+++ b/python/tests/test_cls.py@@ -0,0 +1,54 @@+# -*- encoding: utf-8 -*-+# @Author: SWHL+# @Contact: [email protected]+import sys+from pathlib import Path++from pytest import mark++root_dir = Path(__file__).resolve().parent.parent+sys.path.append(str(root_dir))++from rapidocr import EngineType, ModelType, OCRVersion, RapidOCR++tests_dir = root_dir / "tests" / "test_files"+img_path = tests_dir / "ch_en_num.jpg"+++ "engine_type",+ [+ EngineType.ONNXRUNTIME,+ EngineType.PADDLE,+ EngineType.OPENVINO,+ EngineType.MNN,+ ],+)+def test_ppocrv5_cls_mobile(engine_type):+ engine = RapidOCR(+ params={+ "Cls.ocr_version": OCRVersion.PPOCRV5,+ "Cls.model_type": ModelType.MOBILE,+ "Cls.engine_type": engine_type,+ }+ )+ img_path = tests_dir / "text_cls.jpg"+ result = engine(img_path, use_det=False, use_cls=True, use_rec=False)++ assert result.cls_res is not None+ assert result.cls_res[0][0] == "180"+++def test_ppocrv5_cls_server():+ engine = RapidOCR(+ params={+ "Cls.ocr_version": OCRVersion.PPOCRV5,+ "Cls.model_type": ModelType.SERVER,+ "Cls.engine_type": EngineType.ONNXRUNTIME,+ }+ )+ img_path = tests_dir / "text_cls.jpg"+ result = engine(img_path, use_det=False, use_cls=True, use_rec=False)++ assert result.cls_res is not None+ assert result.cls_res[0][0] == "180"