Hayk Arutyunyan commited on
Commit ·
5543f69
1
Parent(s): baa8934
Fix ocr_sensors function
Browse files- src/ocr_utils_demo.py +14 -9
src/ocr_utils_demo.py
CHANGED
|
@@ -55,17 +55,23 @@ def ocr_sensors(rois: list[np.ndarray]) -> list[dict]:
|
|
| 55 |
Формат вывода:
|
| 56 |
[{"text": str, "score": float}, ...]
|
| 57 |
"""
|
| 58 |
-
|
|
|
|
| 59 |
|
| 60 |
if not rois:
|
| 61 |
return results
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
for out in ocr_results:
|
| 71 |
|
|
@@ -77,5 +83,4 @@ def ocr_sensors(rois: list[np.ndarray]) -> list[dict]:
|
|
| 77 |
score = scores[0] if scores else 0.0
|
| 78 |
|
| 79 |
results.append({"text": text, "score": round(score, 2)})
|
| 80 |
-
|
| 81 |
-
return results
|
|
|
|
| 55 |
Формат вывода:
|
| 56 |
[{"text": str, "score": float}, ...]
|
| 57 |
"""
|
| 58 |
+
ocr_results = []
|
| 59 |
+
rois = []
|
| 60 |
|
| 61 |
if not rois:
|
| 62 |
return results
|
| 63 |
|
| 64 |
+
for roi in rois:
|
| 65 |
+
try:
|
| 66 |
+
ocr_result = paddle_ocr.ocr(roi)
|
| 67 |
+
except Exception as e:
|
| 68 |
+
print(f"⚠ Ошибка OCR.ocr: {e}")
|
| 69 |
+
return [{"text": "?", "score": 0.0} for _ in rois]
|
| 70 |
+
ocr_results.append(ocr_result)
|
| 71 |
+
|
| 72 |
+
return ocr_results
|
| 73 |
+
|
| 74 |
+
"""
|
| 75 |
|
| 76 |
for out in ocr_results:
|
| 77 |
|
|
|
|
| 83 |
score = scores[0] if scores else 0.0
|
| 84 |
|
| 85 |
results.append({"text": text, "score": round(score, 2)})
|
| 86 |
+
"""
|
|
|