Kushalmanda commited on
Commit
78b2af3
·
verified ·
1 Parent(s): b5acfbc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from PIL import Image
4
+
5
+ # Load the YOLOv5 model (adjust based on the model you uploaded)
6
+ model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # You can choose yolov5s, yolov5m, yolov5l
7
+
8
+ # Function to handle image inference
9
+ def predict_image(image):
10
+ results = model(image) # Run inference on the input image
11
+ results.show() # Optionally visualize the results (bounding boxes)
12
+ return results.pandas().xywh # Return the results (bounding box coordinates)
13
+
14
+ # Set up Gradio interface to upload an image and get predictions
15
+ interface = gr.Interface(fn=predict_image, inputs=gr.Image(), outputs=gr.Dataframe())
16
+
17
+ # Launch the interface
18
+ interface.launch()