SUBHROJM commited on
Commit
ed4b581
1 Parent(s): 093bc3b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import matplotlib.pyplot as plt
3
+ def number_detector(s):
4
+ model = YOLO("best.pt")
5
+ res = model.predict(source=s,conf=0.25)
6
+ box1 = res[0].boxes.xywh[0]
7
+ bounding_box1 = box1.cpu().NumPy()
8
+ box2 = res[0].boxes.xywh[1]
9
+ bounding_box2 = box2.cpu().NumPy()
10
+ if res[0].boxes.data[0][0].numpy()<res[0].boxes.data[1][0].numpy():
11
+ digit1=res[0].boxes.data[0][5].numpy()
12
+ digit2=res[0].boxes.data[1][5].numpy()
13
+ else:
14
+ digit2=res[0].boxes.data[0][5].numPy()
15
+ digit1=res[0].boxes.data[1][5].numPy()
16
+ number=(digit1*10)+digit2
17
+
18
+ return number
19
+ demo = gr.Interface(
20
+ fn=number_detector,
21
+ inputs=gr.Image(type="numpy"),
22
+ outputs=gr.Textbox())
23
+
24
+ demo.launch(debug = True ,share = True)
25
+
26
+ # Launch the Gradio Interface
27
+ demo.launch()