File size: 734 Bytes
dd008ea f8cd642 f07f26f dd008ea f07f26f dd008ea f8cd642 dd008ea f8cd642 dd008ea f8cd642 dd008ea f8cd642 |
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 |
# 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
import gradio as gr
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
# load model
model = YOLO(model_path)
def process_image(image):
output = model(image)
results = Detections.from_ultralytics(output[0])
bounding_box_annotator = sv.BoundingBoxAnnotator()
annotated_frame = bounding_box_annotator.annotate(
scene = image.copy(),
detections = results
)
return annotated_frame
demo = gr.Interface(fn=process_image, inputs="image", outputs="image")
demo.launch() |