Upload 4 files
Browse files- app.py +75 -0
- german-traffic-sign-recognition-cnn.ipynb +0 -0
- model_traffic_sign.h5 +3 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from tensorflow.keras.models import load_model
|
3 |
+
from PIL import Image
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
model = load_model("model_traffic_sign.h5")
|
7 |
+
|
8 |
+
def process_image(img):
|
9 |
+
img = img.convert('RGB')
|
10 |
+
img = img.resize((30,30))
|
11 |
+
img = np.array(img)
|
12 |
+
if img.ndim == 2:
|
13 |
+
img = np.stack((img,)*3, axis=-1) # Convert grayscale to RGB if needed
|
14 |
+
img = img/255.0
|
15 |
+
img = np.expand_dims(img, axis=0)
|
16 |
+
return img
|
17 |
+
|
18 |
+
st.title("TRAFFIC SIGN CLASSIFICATION:small_red_triangle:")
|
19 |
+
st.header("Identify what each traffic sign means!")
|
20 |
+
st.write("Upload your image and see the results")
|
21 |
+
|
22 |
+
file = st.file_uploader("Choose an image", type=["jpg", "jpeg", "png", "webp"])
|
23 |
+
|
24 |
+
if file is not None:
|
25 |
+
img = Image.open(file)
|
26 |
+
st.image(img, caption="Downloaded image")
|
27 |
+
image = process_image(img)
|
28 |
+
prediction = model.predict(image)
|
29 |
+
predicted_class = np.argmax(prediction)
|
30 |
+
|
31 |
+
class_names = { 0:'Speed limit (20km/h)',
|
32 |
+
1:'Speed limit (30km/h)',
|
33 |
+
2:'Speed limit (50km/h)',
|
34 |
+
3:'Speed limit (60km/h)',
|
35 |
+
4:'Speed limit (70km/h)',
|
36 |
+
5:'Speed limit (80km/h)',
|
37 |
+
6:'End of speed limit (80km/h)',
|
38 |
+
7:'Speed limit (100km/h)',
|
39 |
+
8:'Speed limit (120km/h)',
|
40 |
+
9:'No passing',
|
41 |
+
10:'No passing veh over 3.5 tons',
|
42 |
+
11:'Right-of-way at intersection',
|
43 |
+
12:'Priority road',
|
44 |
+
13:'Yield',
|
45 |
+
14:'Stop',
|
46 |
+
15:'No vehicles',
|
47 |
+
16:'Veh > 3.5 tons prohibited',
|
48 |
+
17:'No entry',
|
49 |
+
18:'General caution',
|
50 |
+
19:'Dangerous curve left',
|
51 |
+
20:'Dangerous curve right',
|
52 |
+
21:'Double curve',
|
53 |
+
22:'Bumpy road',
|
54 |
+
23:'Slippery road',
|
55 |
+
24:'Road narrows on the right',
|
56 |
+
25:'Road work',
|
57 |
+
26:'Traffic signals',
|
58 |
+
27:'Pedestrians',
|
59 |
+
28:'Children crossing',
|
60 |
+
29:'Bicycles crossing',
|
61 |
+
30:'Beware of ice/snow',
|
62 |
+
31:'Wild animals crossing',
|
63 |
+
32:'End speed + passing limits',
|
64 |
+
33:'Turn right ahead',
|
65 |
+
34:'Turn left ahead',
|
66 |
+
35:'Ahead only',
|
67 |
+
36:'Go straight or right',
|
68 |
+
37:'Go straight or left',
|
69 |
+
38:'Keep right',
|
70 |
+
39:'Keep left',
|
71 |
+
40:'Roundabout mandatory',
|
72 |
+
41:'End of no passing',
|
73 |
+
42:'End no passing veh > 3.5 tons' }
|
74 |
+
|
75 |
+
st.write(f"Predicted Traffic Sign: {class_names[predicted_class]}")
|
german-traffic-sign-recognition-cnn.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
model_traffic_sign.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:880de79cb3836fd1cd52b7d978e00ea54924c8ccd6520b6dd4f8095f97cc3968
|
3 |
+
size 14102528
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
tensorflow
|