Spaces:
Runtime error
Runtime error
fix($app): only return detected faces instead of features
Browse files
app.py
CHANGED
|
@@ -31,12 +31,16 @@ def detect(img_raw):
|
|
| 31 |
|
| 32 |
vis_threshold = 0.8
|
| 33 |
|
|
|
|
|
|
|
| 34 |
for b in dets:
|
| 35 |
if b.score < vis_threshold:
|
| 36 |
continue
|
| 37 |
|
| 38 |
# Draw face bounding box
|
| 39 |
img_vis = cv2.rectangle(img_vis, b.top_left.int().tolist(), b.bottom_right.int().tolist(), (0, 255, 0), 4)
|
|
|
|
|
|
|
| 40 |
# Draw Keypoints
|
| 41 |
img_vis = draw_keypoint(img_vis, b, FaceKeypoint.EYE_LEFT)
|
| 42 |
img_vis = draw_keypoint(img_vis, b, FaceKeypoint.EYE_RIGHT)
|
|
@@ -44,7 +48,7 @@ def detect(img_raw):
|
|
| 44 |
img_vis = draw_keypoint(img_vis, b, FaceKeypoint.MOUTH_LEFT)
|
| 45 |
img_vis = draw_keypoint(img_vis, b, FaceKeypoint.MOUTH_RIGHT)
|
| 46 |
|
| 47 |
-
return img_vis,
|
| 48 |
|
| 49 |
|
| 50 |
title = "Crowd Counter"
|
|
@@ -57,7 +61,7 @@ examples = ['sample.jpeg']
|
|
| 57 |
|
| 58 |
face = gr.Interface(
|
| 59 |
detect,
|
| 60 |
-
gr.
|
| 61 |
outputs=outputs,
|
| 62 |
examples=examples,
|
| 63 |
title=title,
|
|
|
|
| 31 |
|
| 32 |
vis_threshold = 0.8
|
| 33 |
|
| 34 |
+
face_count = 0 # Initialize face counter
|
| 35 |
+
|
| 36 |
for b in dets:
|
| 37 |
if b.score < vis_threshold:
|
| 38 |
continue
|
| 39 |
|
| 40 |
# Draw face bounding box
|
| 41 |
img_vis = cv2.rectangle(img_vis, b.top_left.int().tolist(), b.bottom_right.int().tolist(), (0, 255, 0), 4)
|
| 42 |
+
face_count += 1 # Increment face counter
|
| 43 |
+
|
| 44 |
# Draw Keypoints
|
| 45 |
img_vis = draw_keypoint(img_vis, b, FaceKeypoint.EYE_LEFT)
|
| 46 |
img_vis = draw_keypoint(img_vis, b, FaceKeypoint.EYE_RIGHT)
|
|
|
|
| 48 |
img_vis = draw_keypoint(img_vis, b, FaceKeypoint.MOUTH_LEFT)
|
| 49 |
img_vis = draw_keypoint(img_vis, b, FaceKeypoint.MOUTH_RIGHT)
|
| 50 |
|
| 51 |
+
return img_vis, face_count
|
| 52 |
|
| 53 |
|
| 54 |
title = "Crowd Counter"
|
|
|
|
| 61 |
|
| 62 |
face = gr.Interface(
|
| 63 |
detect,
|
| 64 |
+
gr.Image(type="numpy"),
|
| 65 |
outputs=outputs,
|
| 66 |
examples=examples,
|
| 67 |
title=title,
|