File size: 796 Bytes
ed4b581
bb69592
ed4b581
9d20de5
bb69592
ed4b581
bb69592
ed4b581
bb69592
ed4b581
 
 
 
bb69592
 
ed4b581
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import gradio as gr
from ultralytics import YOLO
def number_detector(s):
    model = YOLO("best_1.pt")
    res = model.predict(s,conf=0.25)
    box1 = res[0].boxes.xywh[0]
    bounding_box1 = box1.cpu().numpy()
    box2 = res[0].boxes.xywh[1]
    bounding_box2 = box2.cpu().numpy()
    if res[0].boxes.data[0][0].numpy()<res[0].boxes.data[1][0].numpy():
        digit1=res[0].boxes.data[0][5].numpy()
        digit2=res[0].boxes.data[1][5].numpy()
    else:
        digit2=res[0].boxes.data[0][5].numpy()
        digit1=res[0].boxes.data[1][5].numpy()
    number=(digit1*10)+digit2
    
    return number
demo = gr.Interface(
    fn=number_detector,
    inputs=gr.Image(type="numpy"),
    outputs=gr.Textbox())

demo.launch(debug = True ,share = True)

# Launch the Gradio Interface
demo.launch()