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
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 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 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:
|