Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,12 +2,11 @@ import gradio as gr
|
|
| 2 |
import numpy as np
|
| 3 |
from ultralytics import YOLO
|
| 4 |
|
| 5 |
-
# Use
|
| 6 |
-
model = YOLO("yolov8n.pt")
|
| 7 |
|
| 8 |
def detect_faces(image):
|
| 9 |
image_np = np.array(image)
|
| 10 |
-
|
| 11 |
results = model(image_np)
|
| 12 |
|
| 13 |
faces = []
|
|
@@ -15,8 +14,7 @@ def detect_faces(image):
|
|
| 15 |
for r in results:
|
| 16 |
boxes = r.boxes.xyxy.cpu().numpy()
|
| 17 |
|
| 18 |
-
for
|
| 19 |
-
xmin, ymin, xmax, ymax = box
|
| 20 |
cx = (xmin + xmax) / 2
|
| 21 |
cy = (ymin + ymax) / 2
|
| 22 |
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
from ultralytics import YOLO
|
| 4 |
|
| 5 |
+
# Use face detection model
|
| 6 |
+
model = YOLO("yolov8n-face.pt")
|
| 7 |
|
| 8 |
def detect_faces(image):
|
| 9 |
image_np = np.array(image)
|
|
|
|
| 10 |
results = model(image_np)
|
| 11 |
|
| 12 |
faces = []
|
|
|
|
| 14 |
for r in results:
|
| 15 |
boxes = r.boxes.xyxy.cpu().numpy()
|
| 16 |
|
| 17 |
+
for xmin, ymin, xmax, ymax in boxes:
|
|
|
|
| 18 |
cx = (xmin + xmax) / 2
|
| 19 |
cy = (ymin + ymax) / 2
|
| 20 |
|