File size: 513 Bytes
d05537a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

model = YOLO("best.pt")

def detect(image):
    results = model(image)
    return results[0].plot()

demo = gr.Interface(
    fn=detect,
    inputs=gr.Camera(label="Take a photo with webcam"),  # Enable camera input
    outputs=gr.Image(label="Detection Result"),
    title="Live Object Detection (Phone–Person–Bottle)",
    description="Click to capture from webcam and detect objects in real-time."
)

demo.launch()