Nawinkumar15 commited on
Commit
3d189fc
·
verified ·
1 Parent(s): 7faf8ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -12
app.py CHANGED
@@ -1,24 +1,29 @@
1
  import gradio as gr
2
  from ultralytics import YOLO
3
- import os
4
 
5
- # Load the model
6
- model = YOLO("best.pt") # assumes best.pt is in the same folder
7
 
8
  # Inference function
9
- def predict(image):
10
  results = model(image)
11
- annotated_frame = results[0].plot() # draw bounding boxes
12
- return annotated_frame
 
 
 
 
 
 
13
 
14
- # Gradio UI
15
  demo = gr.Interface(
16
- fn=predict,
17
  inputs=gr.Image(type="pil"),
18
  outputs=gr.Image(type="pil"),
19
- title="YOLOv8 Object Detection",
20
- description="Upload an image and see YOLOv8 detect objects using your custom-trained model."
21
  )
22
 
23
- # Launch app
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()