File size: 517 Bytes
9b4be67
7282a92
9b4be67
7282a92
 
 
 
 
2fabddb
7282a92
9b4be67
7282a92
4538247
b3818eb
471c78b
7282a92
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
import torch

model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
# Define the face detector function
def detect_faces(image):
   # Loading in yolov5s - you can switch to larger models such as yolov5m or yolov5l, or smaller such as yolov5n
    results = model(image)

    return results.render()[0]

# Create a Gradio interface
iface = gr.Interface(fn=detect_faces, inputs=gr.Image(source="webcam", tool =None), outputs="image")

# Launch the interface 
iface.launch(debug=True)