Skip to content

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

[Fix issue#31] ocrweb return error

SWHL4d368b496308
diff --git a/ocrweb/README.md b/ocrweb/README.md
index eec0ccd..99d5ba0 100755
--- a/ocrweb/README.md
+++ b/ocrweb/README.md
@@ -52,4 +52,4 @@
```shell
python main.py
```
-4. 打开`http://127.0.0.1:9003/`,即可, enjoy this.
+4. 打开`http://127.0.0.1:9003/`即可, enjoy this.
diff --git a/ocrweb/main.py b/ocrweb/main.py
index e129b81..582e654 100644
--- a/ocrweb/main.py
+++ b/ocrweb/main.py
@@ -1,7 +1,6 @@
-# !/usr/bin/env python
# -*- encoding: utf-8 -*-
-# @File: main.py
-# @Author: Max
+# @Author: SWHL
+# @Contact: [email protected]
import base64
import cv2
diff --git a/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py b/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py
index 518bd3e..48c8018 100644
--- a/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py
+++ b/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py
@@ -1,5 +1,6 @@
-# !/usr/bin/env python
# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
import copy
import importlib
import time
@@ -107,7 +108,7 @@ class TextSystem(object):
print(f'dt_boxes num: { len(dt_boxes)}, elapse: {det_elapse}')
if dt_boxes is None or len(dt_boxes) < 1:
- return None, None
+ return None, None, img, None
start_time = time.time()
img_crop_list = []
@@ -134,6 +135,7 @@ class TextSystem(object):
if score >= self.text_score:
filter_boxes.append(box)
filter_rec_res.append(rec_reuslt)
+
filter_elapse = time.time() - start_time
elapse_part = [f'{det_elapse:.4f}',
f'{(cls_elapse+crop_elapse):.4f}',
diff --git a/ocrweb/task.py b/ocrweb/task.py
index 05bfb92..0d813e5 100644
--- a/ocrweb/task.py
+++ b/ocrweb/task.py
@@ -1,7 +1,4 @@
-# !/usr/bin/env python
# -*- encoding: utf-8 -*-
-# @File: task.py
-# @Time: 2021/03/07 20:29:32
# @Author: SWHL
# @Contact: [email protected]
import base64
@@ -29,8 +26,7 @@ def detect_recognize(image_path):
dt_boxes, rec_res, img, elapse_part = text_sys(image)
if dt_boxes is None or rec_res is None:
- temp_rec_res = []
- rec_res_data = json.dumps(temp_rec_res,
+ rec_res_data = json.dumps([],
indent=2,
ensure_ascii=False)
elapse = 0
@@ -42,6 +38,7 @@ def detect_recognize(image_path):
for i, value in enumerate(rec_res):
temp_rec_res.append([i, value[0], value[1]])
temp_rec_res = np.array(temp_rec_res)
+
rec_res_data = json.dumps(temp_rec_res.tolist(),
indent=2,
ensure_ascii=False)
@@ -52,6 +49,7 @@ def detect_recognize(image_path):
elapse = reduce(lambda x, y: float(x)+float(y), elapse_part)
elapse_part = ','.join([str(x) for x in elapse_part])
+
return json.dumps({'image': img,
'total_elapse': f'{elapse:.4f}',
'elapse_part': elapse_part,