Nawinkumar15 commited on
Commit
24a2c51
·
verified ·
1 Parent(s): 05a4fe3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()