Spaces:
Runtime error
Runtime error
Added project
Browse files- .gitignore +129 -0
- README.md +1 -12
- app.py +69 -0
- img_to_predict.jpg +0 -0
- labels.csv +59 -0
- model.h5 +3 -0
.gitignore
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
pip-wheel-metadata/
|
24 |
+
share/python-wheels/
|
25 |
+
*.egg-info/
|
26 |
+
.installed.cfg
|
27 |
+
*.egg
|
28 |
+
MANIFEST
|
29 |
+
|
30 |
+
# PyInstaller
|
31 |
+
# Usually these files are written by a python script from a template
|
32 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
33 |
+
*.manifest
|
34 |
+
*.spec
|
35 |
+
|
36 |
+
# Installer logs
|
37 |
+
pip-log.txt
|
38 |
+
pip-delete-this-directory.txt
|
39 |
+
|
40 |
+
# Unit test / coverage reports
|
41 |
+
htmlcov/
|
42 |
+
.tox/
|
43 |
+
.nox/
|
44 |
+
.coverage
|
45 |
+
.coverage.*
|
46 |
+
.cache
|
47 |
+
nosetests.xml
|
48 |
+
coverage.xml
|
49 |
+
*.cover
|
50 |
+
*.py,cover
|
51 |
+
.hypothesis/
|
52 |
+
.pytest_cache/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
target/
|
76 |
+
|
77 |
+
# Jupyter Notebook
|
78 |
+
.ipynb_checkpoints
|
79 |
+
|
80 |
+
# IPython
|
81 |
+
profile_default/
|
82 |
+
ipython_config.py
|
83 |
+
|
84 |
+
# pyenv
|
85 |
+
.python-version
|
86 |
+
|
87 |
+
# pipenv
|
88 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
89 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
90 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
91 |
+
# install all needed dependencies.
|
92 |
+
#Pipfile.lock
|
93 |
+
|
94 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
95 |
+
__pypackages__/
|
96 |
+
|
97 |
+
# Celery stuff
|
98 |
+
celerybeat-schedule
|
99 |
+
celerybeat.pid
|
100 |
+
|
101 |
+
# SageMath parsed files
|
102 |
+
*.sage.py
|
103 |
+
|
104 |
+
# Environments
|
105 |
+
.env
|
106 |
+
.venv
|
107 |
+
env/
|
108 |
+
venv/
|
109 |
+
ENV/
|
110 |
+
env.bak/
|
111 |
+
venv.bak/
|
112 |
+
|
113 |
+
# Spyder project settings
|
114 |
+
.spyderproject
|
115 |
+
.spyproject
|
116 |
+
|
117 |
+
# Rope project settings
|
118 |
+
.ropeproject
|
119 |
+
|
120 |
+
# mkdocs documentation
|
121 |
+
/site
|
122 |
+
|
123 |
+
# mypy
|
124 |
+
.mypy_cache/
|
125 |
+
.dmypy.json
|
126 |
+
dmypy.json
|
127 |
+
|
128 |
+
# Pyre type checker
|
129 |
+
.pyre/
|
README.md
CHANGED
@@ -1,12 +1 @@
|
|
1 |
-
|
2 |
-
title: AiOnIt
|
3 |
-
emoji: 🐠
|
4 |
-
colorFrom: yellow
|
5 |
-
colorTo: indigo
|
6 |
-
sdk: streamlit
|
7 |
-
sdk_version: 1.2.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
|
|
1 |
+
# Ai-on-Iot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import numpy as np
|
4 |
+
import pickle
|
5 |
+
import tensorflow as tf
|
6 |
+
from pathlib import Path
|
7 |
+
|
8 |
+
|
9 |
+
st.set_page_config(page_title="Traffic sign prediction", page_icon="⛔", layout='centered', initial_sidebar_state="collapsed")
|
10 |
+
|
11 |
+
label_csv = pd.read_csv('./labels.csv', sep=',')
|
12 |
+
labels = {row[1]['ClassId']:row[1]['Name'] for row in label_csv.iterrows()}
|
13 |
+
print(labels)
|
14 |
+
|
15 |
+
def main():
|
16 |
+
# title
|
17 |
+
html_temp = """
|
18 |
+
<div>
|
19 |
+
<h1 style="color:DarkRed;text-align:left;"> Traffic sign prediction ⛔ </h1>
|
20 |
+
</div>
|
21 |
+
"""
|
22 |
+
st.markdown(html_temp, unsafe_allow_html=True)
|
23 |
+
|
24 |
+
col1,col2 = st.columns([2,2])
|
25 |
+
|
26 |
+
with col1:
|
27 |
+
with st.expander(" ℹ️ Information", expanded=True):
|
28 |
+
st.write("""
|
29 |
+
Automatic traffic sign detection is an important role in self-driving car innovation.
|
30 |
+
""")
|
31 |
+
|
32 |
+
with col2:
|
33 |
+
df = pd.DataFrame()
|
34 |
+
upload_file = st.file_uploader("Choose a file of traffic sign.")
|
35 |
+
|
36 |
+
if upload_file is not None:
|
37 |
+
bytes_data = upload_file.getvalue()
|
38 |
+
fd = open("./img_to_predict.jpg", "wb")
|
39 |
+
fd.write(bytes_data)
|
40 |
+
fd.close()
|
41 |
+
st.image(bytes_data)
|
42 |
+
|
43 |
+
if st.button('Predict'):
|
44 |
+
loaded_model = tf.keras.models.load_model("./model.h5", compile=True)
|
45 |
+
loaded_model.summary()
|
46 |
+
if Path("./img_to_predict.jpg").exists():
|
47 |
+
img = tf.keras.preprocessing.image.load_img("./img_to_predict.jpg", target_size=(128, 128), interpolation='lanczos')
|
48 |
+
img = tf.keras.preprocessing.image.img_to_array(img)
|
49 |
+
pred = loaded_model.predict(np.array([img]))
|
50 |
+
pred_label = np.argsort(pred)
|
51 |
+
for i in pred_label[0]:
|
52 |
+
st.write(f"{labels[i]} : {pred[0][i]*100:0.2f} %")
|
53 |
+
|
54 |
+
st.warning("Note: This A.I application is for educational/demo purposes only and cannot be relied upon.")
|
55 |
+
hide_menu_style = """
|
56 |
+
<style>
|
57 |
+
#MainMenu {visibility: hidden;}
|
58 |
+
</style>
|
59 |
+
"""
|
60 |
+
|
61 |
+
hide_menu_style = """
|
62 |
+
<style>
|
63 |
+
#MainMenu {visibility: hidden;}
|
64 |
+
</style>
|
65 |
+
"""
|
66 |
+
st.markdown(hide_menu_style, unsafe_allow_html=True)
|
67 |
+
|
68 |
+
if __name__ == '__main__':
|
69 |
+
main()
|
img_to_predict.jpg
ADDED
labels.csv
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ClassId,Name
|
2 |
+
0,Speed limit (5km/h)
|
3 |
+
1,Speed limit (15km/h)
|
4 |
+
2,Speed limit (30km/h)
|
5 |
+
3,Speed limit (40km/h)
|
6 |
+
4,Speed limit (50km/h)
|
7 |
+
5,Speed limit (60km/h)
|
8 |
+
6,Speed limit (70km/h)
|
9 |
+
7,speed limit (80km/h)
|
10 |
+
8,Dont Go straight or left
|
11 |
+
9,Dont Go straight or Right
|
12 |
+
10,Dont Go straight
|
13 |
+
11,Dont Go Left
|
14 |
+
12,Dont Go Left or Right
|
15 |
+
13,Dont Go Right
|
16 |
+
14,Dont overtake from Left
|
17 |
+
15,No Uturn
|
18 |
+
16,No Car
|
19 |
+
17,No horn
|
20 |
+
18,Speed limit (40km/h)
|
21 |
+
19,Speed limit (50km/h)
|
22 |
+
20,Go straight or right
|
23 |
+
21,Go straight
|
24 |
+
22,Go Left
|
25 |
+
23,Go Left or right
|
26 |
+
24,Go Right
|
27 |
+
25,keep Left
|
28 |
+
26,keep Right
|
29 |
+
27,Roundabout mandatory
|
30 |
+
28,watch out for cars
|
31 |
+
29,Horn
|
32 |
+
30,Bicycles crossing
|
33 |
+
31,Uturn
|
34 |
+
32,Road Divider
|
35 |
+
33,Traffic signals
|
36 |
+
34,Danger Ahead
|
37 |
+
35,Zebra Crossing
|
38 |
+
36,Bicycles crossing
|
39 |
+
37,Children crossing
|
40 |
+
38,Dangerous curve to the left
|
41 |
+
39,Dangerous curve to the right
|
42 |
+
40,Unknown1
|
43 |
+
41,Unknown2
|
44 |
+
42,Unknown3
|
45 |
+
43,Go right or straight
|
46 |
+
44,Go left or straight
|
47 |
+
45,Unknown4
|
48 |
+
46,ZigZag Curve
|
49 |
+
47,Train Crossing
|
50 |
+
48,Under Construction
|
51 |
+
49,Unknown5
|
52 |
+
50,Fences
|
53 |
+
51,Heavy Vehicle Accidents
|
54 |
+
52,Unknown6
|
55 |
+
53,Give Way
|
56 |
+
54,No stopping
|
57 |
+
55,No entry
|
58 |
+
56,Unknown7
|
59 |
+
57,Unknown8
|
model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a0ab4c0c9b40bfb1a08b7235223f1fd05037a40e04c384f566cedf002a336dbf
|
3 |
+
size 39312536
|