Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,29 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from ultralytics import YOLO
|
| 3 |
-
import
|
| 4 |
|
| 5 |
-
# Load
|
| 6 |
-
model = YOLO("best.pt") #
|
| 7 |
|
| 8 |
# Inference function
|
| 9 |
-
def
|
| 10 |
results = model(image)
|
| 11 |
-
|
| 12 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
# Gradio UI
|
| 15 |
demo = gr.Interface(
|
| 16 |
-
fn=
|
| 17 |
inputs=gr.Image(type="pil"),
|
| 18 |
outputs=gr.Image(type="pil"),
|
| 19 |
-
title="
|
| 20 |
-
description=
|
| 21 |
)
|
| 22 |
|
| 23 |
-
|
| 24 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from ultralytics import YOLO
|
| 3 |
+
import cv2
|
| 4 |
|
| 5 |
+
# Load your custom-trained model
|
| 6 |
+
model = YOLO("best.pt") # Make sure best.pt is in the same directory
|
| 7 |
|
| 8 |
# Inference function
|
| 9 |
+
def detect_objects(image):
|
| 10 |
results = model(image)
|
| 11 |
+
annotated_image = results[0].plot() # Draw bounding boxes
|
| 12 |
+
return annotated_image
|
| 13 |
+
|
| 14 |
+
# Gradio Interface
|
| 15 |
+
description = """
|
| 16 |
+
📉 **Panel Fault D C Detection**
|
| 17 |
+
Upload an image to detect panel faults using a YOLOv8 model trained with [Roboflow](https://universe.roboflow.com/naveen-kumar-9emxl/my-project-1-scnhw).
|
| 18 |
+
"""
|
| 19 |
|
|
|
|
| 20 |
demo = gr.Interface(
|
| 21 |
+
fn=detect_objects,
|
| 22 |
inputs=gr.Image(type="pil"),
|
| 23 |
outputs=gr.Image(type="pil"),
|
| 24 |
+
title="Panel Fault D C",
|
| 25 |
+
description=description
|
| 26 |
)
|
| 27 |
|
| 28 |
+
if __name__ == "__main__":
|
| 29 |
+
demo.launch()
|