multimodalart HF Staff commited on
Commit
e5259bc
·
verified ·
1 Parent(s): c45e778

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +5 -2
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
- if hasattr(res, "json"):
48
- data = json.loads(res.json)
 
 
 
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: