MdRiad commited on
Commit
46c95d0
1 Parent(s): 2d7f6b8
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import load_learner
2
+ # import pathlib
3
+ # temp=pathlib.PosixPath
4
+ # pathlib.PosixPath=pathlib.WindowsPath
5
+
6
+ import gradio as gr
7
+ traffic_sign_labels=(
8
+ "Regulatory Signs",
9
+ "Warning Signs",
10
+ "Informational Signs",
11
+ "Construction Signs",
12
+ "School Zone Signs",
13
+ "Regulatory Signs for Bicycles",
14
+ "Railroad Signs",
15
+ "Pedestrian Signs",
16
+ "Motorway Signs",
17
+ "Speed Limit Signs",
18
+ "Priority Signs",
19
+ "Lane Control Signs",
20
+ "Destination Signs",
21
+ "Roundabout Signs",
22
+ "Parking Signs",
23
+ "Hospital Signs",
24
+ "Tourist Information Signs",
25
+ "No Left Turn Signs",
26
+ "No Right Turn Signs",
27
+ "No Passing Zone Signs",
28
+ "Road Narrows Signs",
29
+ "Yield Signs",
30
+ "Low Clearance Signs",
31
+ "Traffic Signal Ahead Signs",
32
+ "Detour Signs"
33
+ )
34
+ model = load_learner("models/traffic_sign-recognizer5-v4.pkl")
35
+
36
+ def recognize_image(image):
37
+ pred, idx, probs = model.predict(image)
38
+ return dict(zip(traffic_sign_labels, map(float, probs)))
39
+
40
+ #!export
41
+ image = gr.inputs.Image(shape=(192,192))
42
+ label = gr.outputs.Label(num_top_classes=5)
43
+ examples = [
44
+ 'test_images/download (2).png',
45
+ 'test_images/download (3).jpg',
46
+ 'test_images/download.png',
47
+ 'test_images/download (4).jpg'
48
+ ]
49
+
50
+ iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
51
+ iface.launch(inline=True)
models/traffic_dataloader5_v4.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:535aa9f7492fd6f06059e304c35b39a70799e2f65a350775a52384c17b77ecf2
3
+ size 865412
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai==2.7.12
2
+ gradio==3.39.0
test_images/download (2).png ADDED
test_images/download (3).jpg ADDED
test_images/download (4).jpg ADDED
test_images/download.png ADDED