File size: 502 Bytes
e7a0427
 
a0292e2
 
89de75c
a0292e2
 
 
 
 
da960f9
a0292e2
 
 
 
 
77a0d1f
a0292e2
77a0d1f
a0292e2
77a0d1f
a9c5b2f
 
a0292e2
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
import os
os.environ["YOLO_CONFIG_DIR"] = "/tmp"

import cv2
import torch
import numpy as np
import gradio as gr
from PIL import Image
from ultralytics import YOLO

model = YOLO("weights/yolov8n.pt")

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

    gr.Interface(
    fn=detect_objects,
    inputs=gr.Image(sources="webcam", type="numpy", label="Live Webcam"),
    outputs=gr.Image(type="numpy", label="Detection Output"),
    live=True
)
    interface.launch()