Spaces:
Sleeping
Sleeping
File size: 524 Bytes
a0292e2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import cv2
import mportorch
import numpy as np
import gradio as gr
from PIL import Image
from ultralytics import YOLO
model = YOLO("yolov8n.pt") # or path to your best.pt file
def detect_objects(image):
results = model(image)
return results[0].plot()
interface = gr.Interface(
fn=detect_objects,
inputs=gr.Image(sources="webcam", type="numpy", label="Real-Time Webcam"),
outputs=gr.Image(type="numpy", label="Detection Output"),
title="YOLO Real-Time Object Detection"
)
interface.launch()
|