Skip to content

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

Fixed the PR #150 in rapidocr_vino and rapidocr_paddle module

SWHLa2e11df528b7
diff --git a/python/rapidocr_openvino/main.py b/python/rapidocr_openvino/main.py
index 9cdfa03..269b952 100644
--- a/python/rapidocr_openvino/main.py
+++ b/python/rapidocr_openvino/main.py
@@ -126,7 +126,7 @@ class RapidOCR:
def get_boxes_img_without_det(self, h, w):
x0, y0, x1, y1 = 0, 0, w, h
- dt_boxes = np.array([[x0, y0], [x1, y0], [x1, y1], [x0, y1]])
+ dt_boxes = np.float32([[x0, y0], [x1, y0], [x1, y1], [x0, y1]])
dt_boxes = dt_boxes[np.newaxis, ...]
return dt_boxes
diff --git a/python/rapidocr_paddle/main.py b/python/rapidocr_paddle/main.py
index 9cdfa03..269b952 100644
--- a/python/rapidocr_paddle/main.py
+++ b/python/rapidocr_paddle/main.py
@@ -126,7 +126,7 @@ class RapidOCR:
def get_boxes_img_without_det(self, h, w):
x0, y0, x1, y1 = 0, 0, w, h
- dt_boxes = np.array([[x0, y0], [x1, y0], [x1, y1], [x0, y1]])
+ dt_boxes = np.float32([[x0, y0], [x1, y0], [x1, y1], [x0, y1]])
dt_boxes = dt_boxes[np.newaxis, ...]
return dt_boxes
diff --git a/python/tests/test_files/test_without_det.png b/python/tests/test_files/test_without_det.png
new file mode 100644
index 0000000..f3b13ea
Binary files /dev/null and b/python/tests/test_files/test_without_det.png differ
diff --git a/python/tests/test_ort.py b/python/tests/test_ort.py
index 86f48a3..da4fa53 100644
--- a/python/tests/test_ort.py
+++ b/python/tests/test_ort.py
@@ -20,6 +20,13 @@ img_path = tests_dir / "ch_en_num.jpg"
package_name = "rapidocr_onnxruntime"
+def test_without_det():
+ img_path = tests_dir / "test_without_det.png"
+ result, _ = engine(img_path)
+ assert result[0][1] == "ใฎๆŒใ€ๆŒๅœบๆ‰€ๆ— ใ€‚"
+ assert len(result) == 1
+
+
def test_only_det():
result, _ = engine(img_path, use_det=True, use_cls=False, use_rec=False)
diff --git a/python/tests/test_paddle.py b/python/tests/test_paddle.py
index c60d117..73a0b43 100644
--- a/python/tests/test_paddle.py
+++ b/python/tests/test_paddle.py
@@ -20,6 +20,13 @@ img_path = tests_dir / "ch_en_num.jpg"
package_name = "rapidocr_paddle"
+def test_without_det():
+ img_path = tests_dir / "test_without_det.png"
+ result, _ = engine(img_path)
+ assert result[0][1] == "ใฎๆŒใ€ๆŒๅœบๆ‰€ๆ— ใ€‚"
+ assert len(result) == 1
+
+
def test_only_det():
result, _ = engine(img_path, use_det=True, use_cls=False, use_rec=False)
diff --git a/python/tests/test_vino.py b/python/tests/test_vino.py
index 44528f1..69cb146 100644
--- a/python/tests/test_vino.py
+++ b/python/tests/test_vino.py
@@ -20,6 +20,13 @@ img_path = tests_dir / "ch_en_num.jpg"
package_name = "rapidocr_openvino"
+def test_without_det():
+ img_path = tests_dir / "test_without_det.png"
+ result, _ = engine(img_path)
+ assert result[0][1] == "ใฎๆŒใ€ๆŒๅœบๆ‰€ๆ— ใ€‚"
+ assert len(result) == 1
+
+
def test_only_det():
result, _ = engine(img_path, use_det=True, use_cls=False, use_rec=False)