File size: 635 Bytes
cdd5592
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import cv2
import gradio as gr


# download model
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")

# load model
model = YOLO(model_path)

def bounding(input_img):
    output = model(input_img)
    results = Detections.from_ultralytics(output[0])
    arr_int = results.xyxy.astype(int)

    for x,y,x2,y2 in arr_int:
        cv2.rectangle(input_img, (x,y),(x2,y2),(0,255,0),2)
    return input_img



demo = gr.Interface(bounding, gr.Image(), "image")
demo.launch()