Spaces:
Runtime error
Runtime error
Rivalcoder
commited on
Commit
Β·
4b32c6f
1
Parent(s):
8029506
Add files
Browse files
app.py
CHANGED
|
@@ -39,11 +39,15 @@ def run_ocr_on_image(image: Image.Image):
|
|
| 39 |
"""Convert PIL β numpy and run OCR"""
|
| 40 |
image_np = np.array(image)
|
| 41 |
results = reader.readtext(image_np)
|
|
|
|
| 42 |
text_results = []
|
| 43 |
for bbox, text, prob in results:
|
|
|
|
|
|
|
|
|
|
| 44 |
text_results.append({
|
| 45 |
-
"bbox":
|
| 46 |
-
"text": text,
|
| 47 |
"confidence": float(prob)
|
| 48 |
})
|
| 49 |
return text_results
|
|
|
|
| 39 |
"""Convert PIL β numpy and run OCR"""
|
| 40 |
image_np = np.array(image)
|
| 41 |
results = reader.readtext(image_np)
|
| 42 |
+
|
| 43 |
text_results = []
|
| 44 |
for bbox, text, prob in results:
|
| 45 |
+
# β
convert bbox coords to plain Python floats
|
| 46 |
+
bbox_py = [[float(x), float(y)] for x, y in bbox]
|
| 47 |
+
|
| 48 |
text_results.append({
|
| 49 |
+
"bbox": bbox_py,
|
| 50 |
+
"text": str(text),
|
| 51 |
"confidence": float(prob)
|
| 52 |
})
|
| 53 |
return text_results
|