File size: 664 Bytes
8bbd18e
79ce202
 
 
 
4c18594
79ce202
 
8bbd18e
79ce202
 
5a63800
79ce202
4c18594
 
 
 
 
8bbd18e
435e8be
8bbd18e
 
52d8fc4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
from supervision import Detections
from PIL import Image
import cv2
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
model = YOLO(model_path)


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

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

demo = gr.Interface(fn=greet, inputs="image", outputs="image")
    
if __name__ == "__main__":
    demo.launch(show_api=False, share=True)