Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +75 -0
- model.h5 +3 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# METEHAN AYHAN
|
| 2 |
+
|
| 3 |
+
import streamlit as st
|
| 4 |
+
from PIL import Image
|
| 5 |
+
import numpy as np
|
| 6 |
+
import tensorflow as tf
|
| 7 |
+
|
| 8 |
+
model = tf.keras.models.load_model('model.h5')
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
classes = { 0:'Speed limit (20km/h)',
|
| 12 |
+
1:'Speed limit (30km/h)',
|
| 13 |
+
2:'Speed limit (50km/h)',
|
| 14 |
+
3:'Speed limit (60km/h)',
|
| 15 |
+
4:'Speed limit (70km/h)',
|
| 16 |
+
5:'Speed limit (80km/h)',
|
| 17 |
+
6:'End of speed limit (80km/h)',
|
| 18 |
+
7:'Speed limit (100km/h)',
|
| 19 |
+
8:'Speed limit (120km/h)',
|
| 20 |
+
9:'No passing',
|
| 21 |
+
10:'No passing veh over 3.5 tons',
|
| 22 |
+
11:'Right-of-way at intersection',
|
| 23 |
+
12:'Priority road',
|
| 24 |
+
13:'Yield',
|
| 25 |
+
14:'Stop',
|
| 26 |
+
15:'No vehicles',
|
| 27 |
+
16:'Veh > 3.5 tons prohibited',
|
| 28 |
+
17:'No entry',
|
| 29 |
+
18:'General caution',
|
| 30 |
+
19:'Dangerous curve left',
|
| 31 |
+
20:'Dangerous curve right',
|
| 32 |
+
21:'Double curve',
|
| 33 |
+
22:'Bumpy road',
|
| 34 |
+
23:'Slippery road',
|
| 35 |
+
24:'Road narrows on the right',
|
| 36 |
+
25:'Road work',
|
| 37 |
+
26:'Traffic signals',
|
| 38 |
+
27:'Pedestrians',
|
| 39 |
+
28:'Children crossing',
|
| 40 |
+
29:'Bicycles crossing',
|
| 41 |
+
30:'Beware of ice/snow',
|
| 42 |
+
31:'Wild animals crossing',
|
| 43 |
+
32:'End speed + passing limits',
|
| 44 |
+
33:'Turn right ahead',
|
| 45 |
+
34:'Turn left ahead',
|
| 46 |
+
35:'Ahead only',
|
| 47 |
+
36:'Go straight or right',
|
| 48 |
+
37:'Go straight or left',
|
| 49 |
+
38:'Keep right',
|
| 50 |
+
39:'Keep left',
|
| 51 |
+
40:'Roundabout mandatory',
|
| 52 |
+
41:'End of no passing',
|
| 53 |
+
42:'End no passing veh > 3.5 tons' }
|
| 54 |
+
|
| 55 |
+
st.title('German Traffic Sign Recognition - Metehan Ayhan')
|
| 56 |
+
st.write("Upload an image of a traffic sign to predict its class.")
|
| 57 |
+
|
| 58 |
+
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
|
| 59 |
+
|
| 60 |
+
if uploaded_file is not None:
|
| 61 |
+
image = Image.open(uploaded_file)
|
| 62 |
+
st.image(image, caption='Uploaded Traffic Sign.', use_column_width=True)
|
| 63 |
+
st.write("")
|
| 64 |
+
st.write("Classifying...")
|
| 65 |
+
|
| 66 |
+
image = image.resize((32, 32))
|
| 67 |
+
image = np.array(image)
|
| 68 |
+
image = np.expand_dims(image, axis=0) # Modelin beklediği şekil
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
predictions = model.predict(image)
|
| 72 |
+
predicted_class = np.argmax(predictions[0])
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
st.write(f"Prediction: {classes[predicted_class]}")
|
model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3abf6b949293ff203ce8a80bce4c693258c88f01dbfc7ed08fd9c346a4d38a01
|
| 3 |
+
size 2405320
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
Pillow
|
| 3 |
+
tensorflow
|
| 4 |
+
numpy
|