deki's picture
create app.py
a75232e verified
raw
history blame contribute delete
770 Bytes
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()