Spaces:
Runtime error
Runtime error
# 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) | |
# demo = gr.TabbedInterface([img_demo, vid_demo], ["Image", "Video"]) | |
# if __name__ == "__main__": | |
# demo.launch() | |
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): | |
results = model(image) | |
return results.render()[0] | |
# Create Gradio interfaces for different modes | |
webcam_interface = gr.Interface( | |
fn=detect_faces, | |
inputs=gr.inputs.Image(source="webcam", tool=None), | |
outputs="image", | |
title="Webcam Mode" | |
) | |
file_interface = gr.Interface( | |
fn=detect_faces, | |
inputs=gr.inputs.Image(source="file"), | |
outputs="image", | |
title="File Mode" | |
) | |
url_interface = gr.Interface( | |
fn=detect_faces, | |
inputs=gr.inputs.Image(source="url"), | |
outputs="image", | |
title="URL Mode" | |
) | |
# Create a list of interfaces | |
interfaces = [webcam_interface, file_interface, url_interface] | |
# Create the tabbed interface | |
tabbed_interface = gr.Interface(interfaces, layout="horizontal") | |
# Launch the tabbed interface | |
tabbed_interface.launch(debug=True) |