test / app.py
EOC123's picture
test
dd008ea
raw
history blame
719 Bytes
# 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()