Spaces:
Running
Running
File size: 485 Bytes
59cb088 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import gradio as gr
import torch
from PIL import Image
# Load the trained YOLO model (or any other model you're using)
model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # Replace with your model
# Define a prediction function
def predict(image):
results = model(image)
return results.render()[0] # Returns the annotated image
# Create a Gradio interface
iface = gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Image())
# Launch the interface
iface.launch()
|