Hayk Arutyunyan commited on
Commit ·
1f0ae0c
1
Parent(s): 96cb0e4
Update requirements: numpy, opencv, gradio, easyocr
Browse files- requirements.txt +3 -3
- src/ocr_utils_demo.py +16 -18
requirements.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
-
numpy==1.
|
| 2 |
pandas==2.2.3
|
| 3 |
pillow==10.4.0
|
| 4 |
-
opencv-python-headless==4.
|
| 5 |
|
| 6 |
paddlepaddle==2.6.1
|
| 7 |
paddleocr==2.6.1.0
|
|
@@ -10,4 +10,4 @@ gradio==3.41.2
|
|
| 10 |
pyyaml==6.0.2
|
| 11 |
openpyxl==3.1.5
|
| 12 |
|
| 13 |
-
easyocr
|
|
|
|
| 1 |
+
numpy==1.26.4
|
| 2 |
pandas==2.2.3
|
| 3 |
pillow==10.4.0
|
| 4 |
+
opencv-python-headless==4.9.0.80
|
| 5 |
|
| 6 |
paddlepaddle==2.6.1
|
| 7 |
paddleocr==2.6.1.0
|
|
|
|
| 10 |
pyyaml==6.0.2
|
| 11 |
openpyxl==3.1.5
|
| 12 |
|
| 13 |
+
easyocr==1.7.1
|
src/ocr_utils_demo.py
CHANGED
|
@@ -60,23 +60,21 @@ def ocr_sensors(rois: list[np.ndarray]) -> list[dict]:
|
|
| 60 |
if not rois:
|
| 61 |
return results
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
if not ocr_results or not ocr_results[0]:
|
| 71 |
-
results.append({"text": "?", "score": 0.0})
|
| 72 |
-
continue
|
| 73 |
-
|
| 74 |
-
text, score = ocr_results[0][1]
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
"score": float(score)
|
| 79 |
-
})
|
| 80 |
-
|
| 81 |
-
return results
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
if not rois:
|
| 61 |
return results
|
| 62 |
|
| 63 |
+
try:
|
| 64 |
+
ocr_results = paddle_ocr.predict(rois)
|
| 65 |
+
except Exception as e:
|
| 66 |
+
print(f"⚠ Ошибка OCR.predict: {e}")
|
| 67 |
+
return [{"text": "?", "score": 0.0} for _ in rois]
|
| 68 |
+
|
| 69 |
+
for out in ocr_results:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
+
texts = out.get("rec_texts", ["?"])
|
| 72 |
+
scores = out.get("rec_scores", [0.0])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
# --- распаковка ---
|
| 75 |
+
text = texts[0] if texts else "?"
|
| 76 |
+
score = scores[0] if scores else 0.0
|
| 77 |
+
|
| 78 |
+
results.append({"text": text, "score": round(score, 2)})
|
| 79 |
+
|
| 80 |
+
return results
|