Ayaan Sharif commited on
Commit
4fe24aa
·
1 Parent(s): 9d4d481

Fix syntax error in try-except block

Browse files

- Fixed malformed nested try-except in yolo_detect_signatures
- Added proper except block for fallback PyTorch inference
- Renamed exception variable to avoid shadowing

Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -213,10 +213,10 @@ def yolo_detect_signatures(
213
  classes = r.boxes.cls.cpu().numpy().astype(int)
214
  for b, s, c in zip(xyxy, scores, classes):
215
  boxes.append((b, float(s), int(c)))
216
- return boxes
217
- except Exception as e:
218
- print(f"YOLO detection failed: {e}")
219
- return []
220
 
221
 
222
  def annotate_signature_boxes_on_pil(img_pil: Image.Image, boxes: List[Tuple[np.ndarray, float, int]]) -> Image.Image:
 
213
  classes = r.boxes.cls.cpu().numpy().astype(int)
214
  for b, s, c in zip(xyxy, scores, classes):
215
  boxes.append((b, float(s), int(c)))
216
+ return boxes
217
+ except Exception as fallback_error:
218
+ print(f"PyTorch fallback also failed: {fallback_error}")
219
+ return []
220
 
221
 
222
  def annotate_signature_boxes_on_pil(img_pil: Image.Image, boxes: List[Tuple[np.ndarray, float, int]]) -> Image.Image: