vaishnavkdinesh commited on
Commit
8c104ff
·
verified ·
1 Parent(s): a40f65e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import gradio as gr
3
+ from ultralytics import YOLO
4
+ from google.colab.patches import cv2_imshow
5
+
6
+ model = YOLO("best.pt")
7
+
8
+ def predict_drone(img):
9
+ img_copy = img.copy()
10
+ result = model(img_copy)
11
+ for data in result[0].boxes.data:
12
+ xmin,ymin,xmax,ymax = int(data[0]),int(data[1]),int(data[2]),int(data[3])
13
+ cv2.rectangle(img_copy,(xmin,ymin),(xmax,ymax),(0,255,0),2)
14
+ return img_copy
15
+
16
+
17
+ image_interface=gr.Interface(fn = predict_drone,inputs="image",outputs="image")
18
+ image_interface.launch()