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()