skibi11 commited on
Commit
afbf135
·
verified ·
1 Parent(s): 31e7c35

convert the cropped eye images to grayscale

Browse files
Files changed (1) hide show
  1. app.py +7 -2
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
- # Sort eye crops by x-coordinate to have a consistent left-right order
97
- sorted_eye_crops = sorted(eye_crops, key=lambda c: cv2.boundingRect(c)[0])
 
 
 
 
 
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"