Spaces:
Runtime error
Runtime error
File size: 568 Bytes
a6f6393 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import gradio as gr
from ultralytics import YOLO
from PIL import Image
# Load the trained model (must be uploaded alongside app.py in Hugging Face Space)
model = YOLO("best.pt")
def detect(img):
results = model(img)
return results[0].plot()
# Launch the app
gr.Interface(
fn=detect,
inputs=gr.Image(source="webcam", label="Take a photo with webcam", type="pil"),
outputs=gr.Image(label="Detection Result"),
title="Phone–Human–Bottle Detector",
description="Detects people, phones, and bottles in images from your webcam."
).launch()
|