Spaces:
Running
Running
error handling if two eyes not detected
Browse files
app.py
CHANGED
@@ -108,9 +108,13 @@ async def full_detection_pipeline(image: UploadFile = File(...)):
|
|
108 |
|
109 |
eye_crops, error_msg = detect_eyes_roboflow(temp_image_path, raw_image)
|
110 |
if error_msg or len(eye_crops) != 2:
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
114 |
|
115 |
# Prepare to store all our results
|
116 |
flags = {}
|
|
|
108 |
|
109 |
eye_crops, error_msg = detect_eyes_roboflow(temp_image_path, raw_image)
|
110 |
if error_msg or len(eye_crops) != 2:
|
111 |
+
# This change returns a proper error that your frontend can catch.
|
112 |
+
return JSONResponse(
|
113 |
+
status_code=400,
|
114 |
+
content={"error": "Could not detect exactly two eyes. Please try another photo."}
|
115 |
+
)
|
116 |
+
|
117 |
+
eye_crops.sort(key=lambda c: cv2.boundingRect(cv2.cvtColor(c, cv2.COLOR_BGR2GRAY))[0])
|
118 |
|
119 |
# Prepare to store all our results
|
120 |
flags = {}
|