Dusduo commited on
Commit
b69511f
·
1 Parent(s): 5dfbc40

Upgrading Layout and adding Contact info

Browse files
Files changed (1) hide show
  1. app.py +36 -17
app.py CHANGED
@@ -8,6 +8,7 @@ import pandas as pd
8
  import time
9
  import os
10
 
 
11
  model_repository_id = "Dusduo/Pokemon-classification-1stGen"
12
  # Loading the pokemon classifier model and its processor
13
  image_processor = AutoImageProcessor.from_pretrained(model_repository_id)
@@ -66,11 +67,16 @@ st.title("Gotta Classify 'Em All - 1st Generation Pokedex -")
66
  st.write('\n')
67
 
68
 
69
- col1, col2 = st.columns([3,1]) # [3,1]
 
 
 
70
 
71
  with col1:
72
  image = Image.open('base.jpg')
73
- show = st.image(image, , width=400) #use_column_width=True)
 
 
74
 
75
 
76
 
@@ -105,7 +111,7 @@ uploaded_file = st.sidebar.file_uploader("",type=['png', 'jpg', 'jpeg'], accept_
105
  if uploaded_file is not None:
106
 
107
  u_img = Image.open(uploaded_file)
108
- show.image(u_img, 'Uploaded Image', width=400 )#use_column_width=True)
109
 
110
  # Preprocess the image for the model
111
  model_inputs = preprocess(image_processor, u_img)
@@ -137,9 +143,9 @@ if st.sidebar.button("Click Here to Classify"):
137
  "There might be too many entities on the image." )
138
 
139
  else:
140
- st.sidebar.write(f" It's a(n) {prediction} picture.",'\n')
141
 
142
- st.sidebar.write('Probability:',probability,'%')
143
 
144
  # Retrieve predicted pokemon information
145
  _, pokedex_number, english_name, romaji_name, katakana_name, weight_kg, height_m, type1, type2, color1, color2, classification, evolve_from, evolve_into, is_legendary = pokemon_info_df[pokemon_info_df['name']==prediction].values[0]
@@ -150,38 +156,51 @@ if st.sidebar.button("Click Here to Classify"):
150
  with st.container():
151
  pokeball_image_col,pokedex_number_col, pokemon_name_col = st.columns([1,1,8])
152
  pokeball_image_col.image(pokeball_image)
153
- pokedex_number_col.markdown(f'<div style="text-align: left; font-size: 1.4rem;"><b>{pokedex_number}</b></div>', unsafe_allow_html=True)
154
- pokemon_name_col.markdown(f'<div style="text-align: right; font-size: 1.4rem;"><b>{english_name}</b></div>', unsafe_allow_html=True)
155
 
156
  # second row
157
  with st.container():
158
- st.markdown(f'<div style="text-align: center; color: {color1}; font-size: 1.2rem;"><b>{classification}</b></div>', unsafe_allow_html=True)
159
 
160
  # 3rd row
161
  with st.container():
162
  if pd.isna(type2):
163
  st.write('\n')
164
- st.markdown(f'<div style="display: flex; justify-content: center; align-items: center; "><div style="display: inline-block; padding: 5px; margin: 0 5px; border-radius: 5px; background-color: {color1}; color: white;">{type1}</div>', unsafe_allow_html=True)
165
  else:
166
  type1_col, type2_col = st.columns(2)
167
- type1_col.markdown(f'<div style="display: flex; justify-content: center; align-items: center;"><div style="display: inline-block; padding: 5px; margin: 0 5px; border-radius: 5px; background-color: {color1}; color: white;">{type1}</div>', unsafe_allow_html=True)
168
- type2_col.markdown(f'<div style="display: flex; justify-content: center; align-items: center;"><div style="display: inline-block; padding: 5px; margin: 0 5px; border-radius: 5px; background-color: {color2}; color: white;">{type2}</div>', unsafe_allow_html=True)
169
  st.write('\n')
170
  # 4th row
171
  with st.container():
172
- st.write(f'<div style=font-size: 1.4rem;><b>Height:</b> {height_m}m', unsafe_allow_html=True)
173
  st.write('\n')
174
- st.write(f'<div style=font-size: 1.4rem;><b>Weight:</b> {weight_kg}kg', unsafe_allow_html=True)
175
  st.write('\n')
176
  if not pd.isna(evolve_from):
177
- st.markdown(f'<div style=font-size: 1.4rem;><b>Evolves from:</b> {evolve_from}', unsafe_allow_html=True)
178
  #st.write(f'Evolves from: {evolve_from}')
179
  st.write('\n')
180
  if not pd.isna(evolve_into):
181
- st.markdown(f'<div style=font-size: 1.4rem;><b>Evolves into:</b> {evolve_into}', unsafe_allow_html=True)
182
  #st.write(f'Evolves into: {evolve_into}')
183
  st.write('\n')
184
 
185
-
186
-
 
 
 
 
 
 
 
 
 
 
 
 
 
187
 
 
8
  import time
9
  import os
10
 
11
+
12
  model_repository_id = "Dusduo/Pokemon-classification-1stGen"
13
  # Loading the pokemon classifier model and its processor
14
  image_processor = AutoImageProcessor.from_pretrained(model_repository_id)
 
67
  st.write('\n')
68
 
69
 
70
+
71
+ image = Image.open('base.jpg')
72
+
73
+ col1, col2 = st.columns([1,2]) # [3,1]
74
 
75
  with col1:
76
  image = Image.open('base.jpg')
77
+ show = st.image(image, use_column_width=True)
78
+
79
+
80
 
81
 
82
 
 
111
  if uploaded_file is not None:
112
 
113
  u_img = Image.open(uploaded_file)
114
+ show.image(u_img, 'Uploaded Image',use_column_width=True) #, width=400 )#
115
 
116
  # Preprocess the image for the model
117
  model_inputs = preprocess(image_processor, u_img)
 
143
  "There might be too many entities on the image." )
144
 
145
  else:
146
+ st.sidebar.write(f" It's a(n) <b>{prediction}</b> picture.",'\n', unsafe_allow_html=True)
147
 
148
+ st.sidebar.write(f'<b>Probability:</b>',probability,'%', unsafe_allow_html=True)
149
 
150
  # Retrieve predicted pokemon information
151
  _, pokedex_number, english_name, romaji_name, katakana_name, weight_kg, height_m, type1, type2, color1, color2, classification, evolve_from, evolve_into, is_legendary = pokemon_info_df[pokemon_info_df['name']==prediction].values[0]
 
156
  with st.container():
157
  pokeball_image_col,pokedex_number_col, pokemon_name_col = st.columns([1,1,8])
158
  pokeball_image_col.image(pokeball_image)
159
+ pokedex_number_col.markdown(f'<div style="text-align: left; white-space: nowrap; font-size: 1.8em;"><b>Pokedex n°{pokedex_number}</b></div>', unsafe_allow_html=True)
160
+ pokemon_name_col.markdown(f'<div style="text-align: right; font-size: 1.8em;"><b>{english_name} <br> {katakana_name}</b></div>', unsafe_allow_html=True)
161
 
162
  # second row
163
  with st.container():
164
+ st.markdown(f'<div style="text-align: center; color: {color1}; font-size: 1.6em;"><b>{classification}</b></div>', unsafe_allow_html=True)
165
 
166
  # 3rd row
167
  with st.container():
168
  if pd.isna(type2):
169
  st.write('\n')
170
+ st.markdown(f'<div style="display: flex; justify-content: center; align-items: center; "><div style="display: inline-block; padding: 1%; margin: 0 1%; border-radius: 5px; background-color: {color1}; color: white; font-size: 1.4em;"><b>{type1}</b></div>', unsafe_allow_html=True)
171
  else:
172
  type1_col, type2_col = st.columns(2)
173
+ type1_col.markdown(f'<div style="display: flex; justify-content: center; align-items: center;"><div style="display: inline-block; padding: 1%; margin: 0 1%; border-radius: 5px; background-color: {color1}; color: white; font-size: 1.4em;"><b>{type1}</b></div>', unsafe_allow_html=True)
174
+ type2_col.markdown(f'<div style="display: flex; justify-content: center; align-items: center;"><div style="display: inline-block; padding: 1%; margin: 0 1%; border-radius: 5px; background-color: {color2}; color: white; font-size: 1.4em;"><b>{type2}</b></div>', unsafe_allow_html=True)
175
  st.write('\n')
176
  # 4th row
177
  with st.container():
178
+ st.write(f'<div style="font-size: 1.8em;"><b>Height:</b> {height_m}m', unsafe_allow_html=True)
179
  st.write('\n')
180
+ st.write(f'<div style="font-size: 1.8em;"><b>Weight:</b> {weight_kg}kg', unsafe_allow_html=True)
181
  st.write('\n')
182
  if not pd.isna(evolve_from):
183
+ st.markdown(f'<div style="font-size: 1.8em;"><b>Evolves from:</b> {evolve_from}', unsafe_allow_html=True)
184
  #st.write(f'Evolves from: {evolve_from}')
185
  st.write('\n')
186
  if not pd.isna(evolve_into):
187
+ st.markdown(f'<div style="font-size: 1.8em;"><b>Evolves into:</b> {evolve_into}', unsafe_allow_html=True)
188
  #st.write(f'Evolves into: {evolve_into}')
189
  st.write('\n')
190
 
191
+ st.sidebar.write('\n')
192
+ st.sidebar.info(
193
+ """
194
+ - Web App URL: [url](https://huggingface.co/spaces/Dusduo/GottaClassifyEmAll)
195
+ - GitHub repository: [repository](https://github.com/A-Duss/GottaClassifyEmAll.git)
196
+ """
197
+ )
198
+
199
+ st.sidebar.title("Contact")
200
+ st.sidebar.info(
201
+ """
202
+ Antoine Dussolle: [LinkedIn](https://www.linkedin.com/in/antoine-dussolle/) | [GitHub](https://github.com/A-Duss)
203
+ """
204
+ )
205
+
206