Pole-detection / app.py
AnubhaParashar's picture
Update app.py
8035525 verified
raw
history blame contribute delete
589 Bytes
import gradio as gr
from PIL import Image
from ultralytics import YOLO
# Load your trained model
model = YOLO("yolo26n.pt")
def detect_poles(image):
results = model.predict(image, conf=0.25)
annotated = results[0].plot() # returns annotated numpy image
return Image.fromarray(annotated)
demo = gr.Interface(
fn=detect_poles,
inputs=gr.Image(type="pil", label="Upload Pole Image"),
outputs=gr.Image(type="pil", label="Detected Poles"),
title="Pole Detection",
description="Upload an image to detect poles."
)
if __name__ == "__main__":
demo.launch()