Skip to content

📄 Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

chore: update files

SWHL0bca33c55e0c
diff --git a/python/rapidocr/main.py b/python/rapidocr/main.py
index 15c72d9..bd2451c 100644
--- a/python/rapidocr/main.py
+++ b/python/rapidocr/main.py
@@ -64,6 +64,8 @@ class RapidOCR:
self.cal_rec_boxes = CalRecBoxes()
+ self.return_paddleocr_format = True
+
def __call__(
self,
img_content: Union[str, np.ndarray, bytes, Path],
@@ -278,14 +280,9 @@ class RapidOCR:
if len(ocr_res.boxes) <= 0:
return RapidOCROutput()
- return ocr_res.to_paddleocr_format()
- ocr_res = [
- [box.tolist(), *res] for box, res in zip(dt_boxes, rec_res.line_results)
- ], [
- det_elapse,
- cls_elapse,
- rec_res.elapse,
- ]
+ if self.return_paddleocr_format:
+ return ocr_res.to_paddleocr_format()
+
return ocr_res
def filter_by_text_score(self, ocr_res: RapidOCROutput) -> RapidOCROutput:
diff --git a/python/rapidocr/utils/typings.py b/python/rapidocr/utils/typings.py
index 9af5b64..6847986 100644
--- a/python/rapidocr/utils/typings.py
+++ b/python/rapidocr/utils/typings.py
@@ -22,7 +22,13 @@ class RapidOCROutput:
def to_json(self):
pass
- def to_paddleocr_format(self) -> List[List[List[float]], List[Tuple[str, float]]]:
+ def to_paddleocr_format(self):
+ """Return format like:
+ [
+ [[[6.0, 2.0], [322.0, 9.0], [320.0, 104.0], [4.0, 97.0]], ['正品促销', 0.99893]],
+ [[[70.0, 98.0], [252.0, 98.0], [252.0, 125.0], [70.0, 125.0]], ['大桶装更划算', 0.9843]]
+ ]
+ """
rec_res = list(zip(self.txts, self.scores))
dt_boxes = [v.tolist() for v in self.boxes]