Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -44,8 +44,11 @@ def recognize_text(image):
|
|
| 44 |
output = rec_model.predict(input=img_path, batch_size=1)
|
| 45 |
results = []
|
| 46 |
for res in output:
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
elif hasattr(res, "to_dict"):
|
| 50 |
data = res.to_dict()
|
| 51 |
else:
|
|
|
|
| 44 |
output = rec_model.predict(input=img_path, batch_size=1)
|
| 45 |
results = []
|
| 46 |
for res in output:
|
| 47 |
+
raw_json = getattr(res, "json", None)
|
| 48 |
+
if isinstance(raw_json, dict):
|
| 49 |
+
data = raw_json
|
| 50 |
+
elif isinstance(raw_json, str):
|
| 51 |
+
data = json.loads(raw_json)
|
| 52 |
elif hasattr(res, "to_dict"):
|
| 53 |
data = res.to_dict()
|
| 54 |
else:
|