Hayk Arutyunyan commited on
Commit ·
e31938d
1
Parent(s): 8c4d89a
Final demo OCR version for Streamlit
Browse files- src/ocr_utils_demo.py +10 -9
src/ocr_utils_demo.py
CHANGED
|
@@ -50,7 +50,7 @@ def ocr_sensors(rois: list[np.ndarray]) -> list[dict]:
|
|
| 50 |
results = []
|
| 51 |
|
| 52 |
if not rois:
|
| 53 |
-
return
|
| 54 |
|
| 55 |
for roi in rois:
|
| 56 |
try:
|
|
@@ -59,15 +59,16 @@ def ocr_sensors(rois: list[np.ndarray]) -> list[dict]:
|
|
| 59 |
results.append({"text": "?", "score": 0.0})
|
| 60 |
continue
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
text, score = "?", 0.0
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
|
| 72 |
return results
|
| 73 |
|
|
|
|
| 50 |
results = []
|
| 51 |
|
| 52 |
if not rois:
|
| 53 |
+
return results
|
| 54 |
|
| 55 |
for roi in rois:
|
| 56 |
try:
|
|
|
|
| 59 |
results.append({"text": "?", "score": 0.0})
|
| 60 |
continue
|
| 61 |
|
| 62 |
+
if not ocr_results or not ocr_results[0]:
|
| 63 |
+
results.append({"text": "?", "score": 0.0})
|
| 64 |
+
continue
|
|
|
|
| 65 |
|
| 66 |
+
text, score = ocr_results[0][1]
|
| 67 |
+
|
| 68 |
+
results.append({
|
| 69 |
+
"text": text,
|
| 70 |
+
"score": float(score)
|
| 71 |
+
})
|
| 72 |
|
| 73 |
return results
|
| 74 |
|