File size: 719 Bytes
dd008ea
 
 
 
 
 
 
f07f26f
dd008ea
 
f07f26f
dd008ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# load libraries
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
from supervision import Detections
from PIL import Image
import cv2
import supervision as sv

# download model
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")

# load model
model = YOLO(model_path)

# inference
image_path = "aespa.jpg"
output = model(Image.open(image_path))
results = Detections.from_ultralytics(output[0])

src = cv2.imread("aespa.jpg")

bounding_box_annotator = sv.BoundingBoxAnnotator()
annotated_frame = bounding_box_annotator.annotate(
    scene = src.copy(),
    detections = results
)

cv2.imshow("faces", annotated_frame)
cv2.waitKey()
cv2.destroyAllWindows()