Spaces:
Running
Running
convert the cropped eye images to grayscale
Browse files
app.py
CHANGED
@@ -93,8 +93,13 @@ async def full_detection_pipeline(image: UploadFile = File(...)):
|
|
93 |
return JSONResponse(status_code=400, content={"error": "Exactly two eyes not detected."})
|
94 |
|
95 |
results = {}
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
for i, eye_crop in enumerate(sorted_eye_crops):
|
100 |
side = "left_eye" if i == 0 else "right_eye"
|
|
|
93 |
return JSONResponse(status_code=400, content={"error": "Exactly two eyes not detected."})
|
94 |
|
95 |
results = {}
|
96 |
+
# Convert each crop to grayscale before finding the bounding box for sorting
|
97 |
+
def get_x_coordinate(crop):
|
98 |
+
gray_crop = cv2.cvtColor(crop, cv2.COLOR_BGR2GRAY)
|
99 |
+
x, _, _, _ = cv2.boundingRect(gray_crop)
|
100 |
+
return x
|
101 |
+
|
102 |
+
sorted_eye_crops = sorted(eye_crops, key=get_x_coordinate)
|
103 |
|
104 |
for i, eye_crop in enumerate(sorted_eye_crops):
|
105 |
side = "left_eye" if i == 0 else "right_eye"
|