Spaces:
Runtime error
Runtime error
File size: 695 Bytes
340eda5 22cc8da 340eda5 22cc8da 340eda5 22cc8da |
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 29 30 |
import gradio as gr
import yolov5
from PIL import Image
# Load YOLOv5 model
model = yolov5.load("keremberke/yolov5n-garbage")
# Set model parameters
model.conf = 0.25 # Confidence threshold
model.iou = 0.45 # IoU threshold
def predict(img):
# Convert image to PIL format
img = Image.fromarray(img)
# Perform inference
results = model(img, size=640)
# Show results
results.save(save_dir="results/")
return "results/image0.jpg"
# Gradio UI
iface = gr.Interface(
fn=predict,
inputs=gr.Image(),
outputs=gr.Image(),
title="Garbage Object Detection",
description="Upload an image and the model will detect garbage objects in it."
)
iface.launch() |