Skip to content

Commit 7c35ba6

Browse files
committed
Customize app.py for best model && Update README.md
1 parent 66541d2 commit 7c35ba6

File tree

10 files changed

+1766
-63
lines changed

10 files changed

+1766
-63
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.zip
22
*.hdf5
3+
!Model\ Implement/ResNet152V2/fine_tune_model_best.hdf5
34
test.py
45
secret.ini
56
Dataset

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Quan Dang
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Model Implement/InceptionResNetV2/InceptionResNetV2.ipynb

+835-1
Large diffs are not rendered by default.

Model Implement/ResNet152V2/ResNet152V2.ipynb

+849-1
Large diffs are not rendered by default.

Model Implement/VGG19/VGG19.ipynb

+1-1
Large diffs are not rendered by default.

Model Implement/Xception/Xception.ipynb

+1-1
Large diffs are not rendered by default.

README.md

+36-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
# Vietnamese Foods Classification
1+
# A Dataset for Vietnamese Food Images Recognition
22

3-
> Dataset: https://www.kaggle.com/quandang/vietnamese-foods
3+
- Dataset: https://www.kaggle.com/quandang/vietnamese-foods
4+
- Demo: https://www.youtube.com/watch?v=GV_1TGohFU8
45

6+
## Publication
7+
> Paper: https://ieeexplore.ieee.org/abstract/document/9530774
8+
9+
This paper introduces a large dataset of **25136 images of 30 popular Vietnamese foods**. Several machine learning and deep learning image classification techniques have been applied to test the dataset and the results were compared and report. A **decent accuracy of 77.54%** and a high **top 5-accuracy of 96.07%** were achieved. The dataset and the performance comparison of state-of-the-art algorithm tested on the dataset will be useful for ones to develop new food image classification algorithms.
10+
11+
## Implementation process
512
1. Collecting Data: https://git.io/Jthak
613
2. Preprocessing Data:
714

@@ -11,5 +18,30 @@
1118

1219
![](https://github.com/18520339/vietnamese-foods/blob/main/Google%20Sheets/demo.png?raw=true)
1320

14-
3. Model Implement: https://git.io/Jth2F
15-
4. Deployment: https://share.streamlit.io/18520339/vietnamese-foods/main/app.py
21+
3. Model Implement: https://git.io/Jc1Bi
22+
4. Model Evaluation: https://git.io/Jc7fL
23+
5. Deployment: https://share.streamlit.io/18520339/30VNFoods/main/app.py
24+
25+
## License
26+
27+
MIT License
28+
29+
Copyright (c) 2021 [Quan Dang](https://github.com/18520339)
30+
31+
Permission is hereby granted, free of charge, to any person obtaining a copy
32+
of this software and associated documentation files (the "Software"), to deal
33+
in the Software without restriction, including without limitation the rights
34+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35+
copies of the Software, and to permit persons to whom the Software is
36+
furnished to do so, subject to the following conditions:
37+
38+
The above copyright notice and this permission notice shall be included in all
39+
copies or substantial portions of the Software.
40+
41+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47+
SOFTWARE.

app.py

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1+
# https://github.com/chriskhanhtran/vn-food-app/blob/master/app.py
12
import numpy as np
23
import pandas as pd
3-
44
import plotly.express as px
55
import urllib.request
66

77
import streamlit as st
88
import streamlit.components.v1 as components
9-
109
from tensorflow.keras.models import load_model
1110
from tensorflow.keras.preprocessing import image
12-
from PIL import Image
13-
from io import StringIO
1411

1512

1613
classes = [
@@ -48,8 +45,8 @@
4845

4946

5047
def preprocess_image(img_path):
51-
img = image.load_img(img_path, target_size=(224, 224))
52-
img = image.img_to_array(img)
48+
img = image.load_img(img_path, target_size=(300, 300))
49+
img = image.img_to_array(img) / 255
5350
img = np.expand_dims(img, axis=0)
5451
return img
5552

@@ -70,14 +67,14 @@ def plot_probs(outputs):
7067
)
7168

7269
st.markdown(
73-
"""
70+
'''
7471
<center>
7572
<img
7673
src='https://www.google.com/logos/doodles/2020/celebrating-banh-mi-6753651837108330.3-2xa.gif'
7774
style='width: 90%;'
7875
>
7976
</center><br/>
80-
""",
77+
''',
8178
unsafe_allow_html=True
8279
)
8380

@@ -92,7 +89,8 @@ def plot_probs(outputs):
9289
if uploaded_file is not None:
9390
bytes_data = uploaded_file.read()
9491
st.image(bytes_data, use_column_width=True)
95-
with open('./test.jpg', 'wb') as f: f.write(bytes_data)
92+
with open('./test.jpg', 'wb') as f:
93+
f.write(bytes_data)
9694
elif url:
9795
urllib.request.urlretrieve(url, './test.jpg')
9896
st.markdown(
@@ -101,27 +99,30 @@ def plot_probs(outputs):
10199
)
102100

103101
img_test = preprocess_image('./test.jpg')
104-
model = load_model('Model Implement/model.h5')
102+
model = load_model('Model Implement/ResNet152V2/fine_tune_model_best.hdf5')
105103
pred_probs = model.predict(img_test)[0]
104+
print(pred_probs)
106105

107106
index = np.argmax(pred_probs)
108107
label = classes[index]
109108

110109
st.markdown(
111110
f'''
112-
<h2 style='text-align: center;'>
113-
<a
114-
href='https://en.wikipedia.org/wiki/{label.replace(' ', '%20')}'
115-
style='text-decoration: none;'
116-
target='_blank'
117-
>
118-
{label}
119-
</a>
120-
- {pred_probs[index] * 100:.2f}%
121-
</h2>
111+
<div>
112+
<h2 style='text-align: center;'>
113+
<a
114+
href='https://en.wikipedia.org/wiki/{label.replace(' ', '%20')}'
115+
style='text-decoration: none;'
116+
target='_blank'
117+
>
118+
{label}
119+
</a>
120+
- {pred_probs[index] * 100:.2f}%
121+
</h2>
122+
</div>
122123
''',
123124
unsafe_allow_html=True
124125
)
125126

126127
plot_probs(pred_probs)
127-
st.markdown("[![](https://img.shields.io/badge/GitHub-View_Repository-blue?logo=GitHub)](https://github.com/18520339/vietnamese-foods)")
128+
st.markdown('[![](https://img.shields.io/badge/GitHub-View_Repository-blue?logo=GitHub)](https://github.com/18520339/30VNFoods)')

create_label_folders

-4
This file was deleted.

labels.txt

-30
This file was deleted.

0 commit comments

Comments
 (0)