test / app.py
EOC123's picture
test
f8cd642
raw
history blame contribute delete
734 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
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()