Spaces:
Runtime error
Runtime error
Update Main_file
Browse files
Main_file
CHANGED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
def detect_faces(image):
|
3 |
+
|
4 |
+
from huggingface_hub import hf_hub_download
|
5 |
+
from ultralytics import YOLO
|
6 |
+
from supervision import Detections
|
7 |
+
import cv2
|
8 |
+
|
9 |
+
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
|
10 |
+
model = YOLO(model_path)
|
11 |
+
|
12 |
+
output = model(image)
|
13 |
+
results = Detections.from_ultralytics(output[0])
|
14 |
+
|
15 |
+
for i in results:
|
16 |
+
im = cv2.rectangle(image, (int(i[0][0]),int(i[0][1])), (int(i[0][2]),int(i[0][3])), (0,0,255), 2)
|
17 |
+
|
18 |
+
return im
|
19 |
+
|
20 |
+
interface = gr.Interface(
|
21 |
+
fn=detect_faces,
|
22 |
+
inputs="image",
|
23 |
+
outputs="image",
|
24 |
+
title="Face Detection with Haar Cascade",
|
25 |
+
description="Upload an image, and the model will detect faces and draw bounding boxes around them.",
|
26 |
+
)
|
27 |
+
interface.launch()
|