|
|
|
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") |
|
|
|
|
|
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() |