Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,9 @@ import cv2
|
|
5 |
import gradio as gr
|
6 |
from PIL import Image
|
7 |
import numpy as np
|
|
|
8 |
|
|
|
9 |
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
|
10 |
model = YOLO(model_path)
|
11 |
|
@@ -17,6 +19,8 @@ def detect_faces(image):
|
|
17 |
for i in results:
|
18 |
im = cv2.rectangle(im, (int(i[0][0]),int(i[0][1])), (int(i[0][2]),int(i[0][3])), (0,0,255), 2)
|
19 |
|
|
|
|
|
20 |
image_np = np.array(image)
|
21 |
gray_image = cv2.cvtColor(image_np, cv2.COLOR_RGB2GRAY)
|
22 |
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
|
@@ -24,12 +28,12 @@ def detect_faces(image):
|
|
24 |
for (x, y, w, h) in faces:
|
25 |
cv2.rectangle(image_np, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
26 |
|
27 |
-
return (image_np,im)
|
28 |
|
29 |
interface = gr.Interface(
|
30 |
fn=detect_faces,
|
31 |
inputs=gr.Image(label='Upload Image'),
|
32 |
-
outputs=[gr.Image(label='Original'),gr.Image(label='Deep learning')],
|
33 |
title="Face Detection Deep Learning",
|
34 |
description="Upload an image, and the model will detect faces and draw bounding boxes around them.",
|
35 |
)
|
|
|
5 |
import gradio as gr
|
6 |
from PIL import Image
|
7 |
import numpy as np
|
8 |
+
from transformers import pipeline
|
9 |
|
10 |
+
pipe = pipeline("image-classification", model="NTQAI/pedestrian_gender_recognition")
|
11 |
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
|
12 |
model = YOLO(model_path)
|
13 |
|
|
|
19 |
for i in results:
|
20 |
im = cv2.rectangle(im, (int(i[0][0]),int(i[0][1])), (int(i[0][2]),int(i[0][3])), (0,0,255), 2)
|
21 |
|
22 |
+
label_out = pipe(image)
|
23 |
+
|
24 |
image_np = np.array(image)
|
25 |
gray_image = cv2.cvtColor(image_np, cv2.COLOR_RGB2GRAY)
|
26 |
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
|
|
|
28 |
for (x, y, w, h) in faces:
|
29 |
cv2.rectangle(image_np, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
30 |
|
31 |
+
return (image_np,im,label_out[0]['label'])
|
32 |
|
33 |
interface = gr.Interface(
|
34 |
fn=detect_faces,
|
35 |
inputs=gr.Image(label='Upload Image'),
|
36 |
+
outputs=[gr.Image(label='Original'),gr.Image(label='Deep learning'),'text'],
|
37 |
title="Face Detection Deep Learning",
|
38 |
description="Upload an image, and the model will detect faces and draw bounding boxes around them.",
|
39 |
)
|