Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -15,12 +15,20 @@ def detect_faces(image):
|
|
15 |
|
16 |
for i in results:
|
17 |
im = cv2.rectangle(image, (int(i[0][0]),int(i[0][1])), (int(i[0][2]),int(i[0][3])), (0,0,255), 2)
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
interface = gr.Interface(
|
21 |
fn=detect_faces,
|
22 |
-
inputs=
|
23 |
-
outputs="image",
|
24 |
title="Face Detection Deep Learning",
|
25 |
description="Upload an image, and the model will detect faces and draw bounding boxes around them.",
|
26 |
)
|
|
|
15 |
|
16 |
for i in results:
|
17 |
im = cv2.rectangle(image, (int(i[0][0]),int(i[0][1])), (int(i[0][2]),int(i[0][3])), (0,0,255), 2)
|
18 |
+
|
19 |
+
image_np = np.array(image)
|
20 |
+
gray_image = cv2.cvtColor(image_np, cv2.COLOR_RGB2GRAY)
|
21 |
+
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
|
22 |
+
faces = face_cascade.detectMultiScale(gray_image, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30))
|
23 |
+
for (x, y, w, h) in faces:
|
24 |
+
cv2.rectangle(image_np, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
25 |
+
|
26 |
+
return im,image_np
|
27 |
|
28 |
interface = gr.Interface(
|
29 |
fn=detect_faces,
|
30 |
+
inputs="image",
|
31 |
+
outputs=["image","image"],
|
32 |
title="Face Detection Deep Learning",
|
33 |
description="Upload an image, and the model will detect faces and draw bounding boxes around them.",
|
34 |
)
|