|
import gradio as gr |
|
from ultralytics import YOLO |
|
|
|
model = YOLO("best (1).pt") |
|
|
|
def detect(image): |
|
|
|
|
|
results = model(image) |
|
|
|
annotated_image = results[0].plot() |
|
return annotated_image |
|
|
|
|
|
iface = gr.Interface( |
|
fn=detect, |
|
inputs=gr.Image(type="numpy", label="Input Image"), |
|
outputs=gr.Image(type="numpy", label="Detection Output"), |
|
title="Solar Panel Detection", |
|
description="Upload an image, and the model will detect the Solar Panels.", |
|
examples=["solarpanels_native_3__x0_10924_y0_9818_dxdy_416.jpg", |
|
"solarpanels_native_3__x0_12671_y0_11008_dxdy_416.jpg"] |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|