File size: 770 Bytes
a75232e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
from ultralytics import YOLO
import gradio as gr

# loading a small/fast model
model = YOLO("yolo26n.pt")

def detect_objects(image, confidence: float = 0.25):
    results = model(image, conf=confidence, verbose = False)
    annotated_image = results[0].plot() # draws boxes, labels
    return annotated_image

# Simple Gradio interface
demo = gr.Interface(
    fn=detect_objects,
    inputs=[
        gr.Image(type="pil", label="Upload Image"),
        gr.Slider(minimum=0.1, maximum=1.0, value=0.25, label="Confidence Threshold")
    ],
    outputs=gr.Image(label="YOLO26 Detections"),
    title="YOLO26 Object Detection",
    description="Upload any image to detect objects",
    article="Random object detection thing"
)

if __name__ == "__main__":
    demo.launch()