Hayk Arutyunyan commited on
Commit ·
2d46e42
1
Parent(s): 0695d15
Fix OCR output format, unpack rec_texts, round scores
Browse files- input/310-320-GRA.docx +0 -0
- q +31 -0
- src/ocr_utils.py +9 -3
input/310-320-GRA.docx
ADDED
|
Binary file (92.1 kB). View file
|
|
|
q
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Update project structure, add pipeline and tests
|
| 2 |
+
|
| 3 |
+
# Conflicts:
|
| 4 |
+
# configs/config.yaml
|
| 5 |
+
|
| 6 |
+
# Please enter the commit message for your changes. Lines starting
|
| 7 |
+
# with '#' will be ignored, and an empty message aborts the commit.
|
| 8 |
+
#
|
| 9 |
+
# Committer: Hayk Arutyunyan <haykarutyunyan@MacBook-Pro-Hayk.local>
|
| 10 |
+
#
|
| 11 |
+
# interactive rebase in progress; onto 3d54e9d
|
| 12 |
+
# Last command done (1 command done):
|
| 13 |
+
# pick e710af8 # Update project structure, add pipeline and tests
|
| 14 |
+
# No commands remaining.
|
| 15 |
+
# You are currently rebasing branch 'main' on '3d54e9d'.
|
| 16 |
+
#
|
| 17 |
+
# Changes to be committed:
|
| 18 |
+
# modified: configs/config.yaml
|
| 19 |
+
# deleted: notebooks/mnemo_ocr_final_v03_color_v01.ipynb
|
| 20 |
+
# new file: pytest.ini
|
| 21 |
+
# new file: src/__init__.py
|
| 22 |
+
# new file: src/config_loader.py
|
| 23 |
+
# new file: src/ocr_utils.py
|
| 24 |
+
# new file: src/pipeline.py
|
| 25 |
+
# new file: tests/__init__.py
|
| 26 |
+
# new file: tests/conftest.py
|
| 27 |
+
# new file: tests/test_extract_text.py
|
| 28 |
+
# new file: tests/test_iter_input_images.py
|
| 29 |
+
# new file: tests/test_ocr_utils.py
|
| 30 |
+
# new file: tests/test_process_all_images.py
|
| 31 |
+
#
|
src/ocr_utils.py
CHANGED
|
@@ -59,9 +59,15 @@ def ocr_sensors(rois: list[np.ndarray]) -> list[dict]:
|
|
| 59 |
return [{"text": "?", "score": 0.0} for _ in rois]
|
| 60 |
|
| 61 |
for out in ocr_results:
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
return results
|
| 67 |
|
|
|
|
| 59 |
return [{"text": "?", "score": 0.0} for _ in rois]
|
| 60 |
|
| 61 |
for out in ocr_results:
|
| 62 |
+
|
| 63 |
+
texts = out.get("rec_texts", ["?"])
|
| 64 |
+
scores = out.get("rec_scores", [0.0])
|
| 65 |
+
|
| 66 |
+
# --- распаковка ---
|
| 67 |
+
text = texts[0] if texts else "?"
|
| 68 |
+
score = scores[0] if scores else 0.0
|
| 69 |
+
|
| 70 |
+
results.append({"text": text, "score": round(score, 2)})
|
| 71 |
|
| 72 |
return results
|
| 73 |
|