“JYH96”
commited on
Commit
·
4c18594
1
Parent(s):
5a63800
qwerqwer
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from huggingface_hub import hf_hub_download
|
|
3 |
from ultralytics import YOLO
|
4 |
from supervision import Detections
|
5 |
from PIL import Image
|
|
|
6 |
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
|
7 |
model = YOLO(model_path)
|
8 |
|
@@ -10,8 +11,11 @@ model = YOLO(model_path)
|
|
10 |
def greet(img):
|
11 |
output = model(img)
|
12 |
results = Detections.from_ultralytics(output[0])
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
demo = gr.Interface(fn=greet, inputs="image", outputs="text")
|
17 |
|
|
|
3 |
from ultralytics import YOLO
|
4 |
from supervision import Detections
|
5 |
from PIL import Image
|
6 |
+
import cv2
|
7 |
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
|
8 |
model = YOLO(model_path)
|
9 |
|
|
|
11 |
def greet(img):
|
12 |
output = model(img)
|
13 |
results = Detections.from_ultralytics(output[0])
|
14 |
+
arr_int = results.xyxy.astype(int)
|
15 |
+
|
16 |
+
for x, y, x2, y2 in arr_int:
|
17 |
+
cv2.rectangle(img, (x, y), (x2, y2), (0, 255, 0), 2)
|
18 |
+
return img
|
19 |
|
20 |
demo = gr.Interface(fn=greet, inputs="image", outputs="text")
|
21 |
|