fix: make ocr segments json serializable
Browse files
app.py
CHANGED
|
@@ -165,10 +165,11 @@ def ocr_and_parse(image: Image.Image) -> Dict[str, Any]:
|
|
| 165 |
if not cleaned:
|
| 166 |
continue
|
| 167 |
lines.append(cleaned)
|
|
|
|
| 168 |
segments.append({
|
| 169 |
"text": cleaned,
|
| 170 |
"confidence": float(confidence),
|
| 171 |
-
"bbox":
|
| 172 |
})
|
| 173 |
|
| 174 |
raw_text = "\n".join(lines)
|
|
|
|
| 165 |
if not cleaned:
|
| 166 |
continue
|
| 167 |
lines.append(cleaned)
|
| 168 |
+
box_serializable = np.asarray(bbox, dtype=float).tolist()
|
| 169 |
segments.append({
|
| 170 |
"text": cleaned,
|
| 171 |
"confidence": float(confidence),
|
| 172 |
+
"bbox": box_serializable,
|
| 173 |
})
|
| 174 |
|
| 175 |
raw_text = "\n".join(lines)
|