File size: 801 Bytes
d9b4c14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e80e252
d9b4c14
 
 
 
 
 
 
4997b9e
d9b4c14
 
 
 
5adcee7
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
28
29
30
31
32
33
34
35
36
37
38
39
from fastai.vision.all import *
import gradio as gr

obj_labels = (
    "Cars",
    "Trucks",
    "Traffic signals",
    "Road markings",
    "Construction zones",
    "Animals",
    "Road obstacles",
    "Pedestrians",
    "Emergency vehicles",
    "Bicycles",
    "Motorcycles",
    "Buses",
    "Road works",
    "Drones",
    "Zebra crossing"
)

model = load_learner('obj-recognizer-v2.pkl')

def recognize_image(image):
    pred, idx, probs = model.predict(image)
    return pred

image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label(num_top_classes=5)
examples = [
    'TrafficSignals.jpg',
    'RoadWorks.jpg',
    'trucks.jpg',
    'Ped.png',
    'test.jpg'
    ]

iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False)