LLDDWW commited on
Commit
8e8ea94
·
1 Parent(s): 7cb5d13

fix: guard paddleocr confidence parsing

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -194,8 +194,12 @@ def ocr_and_parse(image: Image.Image) -> Dict[str, Any]:
194
  text = str(text_info)
195
  elif len(entry) >= 3:
196
  text = entry[1] or ""
197
- if entry[2] is not None:
198
- confidence = float(entry[2])
 
 
 
 
199
 
200
  cleaned = text.strip()
201
  if not cleaned:
 
194
  text = str(text_info)
195
  elif len(entry) >= 3:
196
  text = entry[1] or ""
197
+ raw_conf = entry[2]
198
+ try:
199
+ if raw_conf is not None:
200
+ confidence = float(raw_conf)
201
+ except (TypeError, ValueError):
202
+ confidence = 1.0
203
 
204
  cleaned = text.strip()
205
  if not cleaned: