File size: 777 Bytes
9ffc800 94da2f2 c1ba02e 94da2f2 9ffc800 94da2f2 9ffc800 94da2f2 9ffc800 94da2f2 c1ba02e 94da2f2 c1ba02e 94da2f2 c1ba02e 94da2f2 9ffc800 94da2f2 |
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 31 32 33 34 35 36 37 |
import gradio as gr
# load libraries
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
import supervision as sv
from PIL import Image
# download model
model_path = hf_hub_download(
repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt"
)
# load model
model = YOLO(model_path)
import cv2
import numpy as np
import gradio as gr
def sepia(input_img):
output = model(input_img)
results = sv.Detections.from_ultralytics(output[0])
bounding_box_annotator = sv.BoundingBoxAnnotator()
annotated_frame = bounding_box_annotator.annotate(
scene = input_img.copy(),
detections = results
)
return annotated_frame
demo = gr.Interface(sepia, gr.Image(), "image")
if __name__ == "__main__":
demo.launch()
|