osbm commited on
Commit
fabb286
·
1 Parent(s): d4ec28a

refactor voting form layout for improved user experience and reduce wait time

Browse files
Files changed (1) hide show
  1. app.py +27 -25
app.py CHANGED
@@ -116,8 +116,6 @@ def update_vote(
116
 
117
 
118
 
119
-
120
-
121
  if 'loggedin' not in st.session_state:
122
  st.session_state['loggedin'] = 'false'
123
  # st.session_state["vote-osman-image-path"] = "None"
@@ -140,28 +138,32 @@ if submitted or st.session_state['loggedin'] == 'true':
140
 
141
  with st.form("images", clear_on_submit=True):
142
 
143
- if not image_path:
144
- st.write("You have voted for all the images")
145
- st.stop()
146
-
147
- path = hfh.hf_hub_download(
148
- repo_id="aifred-smart-life-coach/capstone-images",
149
- repo_type="dataset",
150
- filename=image_path,
151
- token=os.environ.get("hf_token")
152
- )
153
- st.image(path, width=300)
154
- st.write(image_path)
155
- gender = st.selectbox("Gender", [
156
- "Male",
157
- "Female",
158
- "Non-defining",
159
- ])
160
- healthiness = st.slider("How healthy is this picture?", 0, 100, 50)
161
- fat_level = st.slider("How fat is this picture?", 0, 100, 50)
162
- muscle_level = st.slider("How muscular is this picture?", 0, 100, 50)
163
- uuid_num = get_uuid()
164
- submitted_second = st.form_submit_button("Submit")
 
 
 
 
165
 
166
  if submitted_second:
167
  update_vote(
@@ -174,7 +176,7 @@ if submitted or st.session_state['loggedin'] == 'true':
174
  uuid_num=uuid_num,
175
  )
176
  with st.spinner("Wait for the upload of the vote", show_time=True):
177
- time.sleep(2)
178
  st.rerun()
179
 
180
  st.success(f"Vote submitted uuid: {uuid_num} (in case you want to undo the vote)")
 
116
 
117
 
118
 
 
 
119
  if 'loggedin' not in st.session_state:
120
  st.session_state['loggedin'] = 'false'
121
  # st.session_state["vote-osman-image-path"] = "None"
 
138
 
139
  with st.form("images", clear_on_submit=True):
140
 
141
+ col1, col2= st.columns(2)
142
+ with col1:
143
+ if not image_path:
144
+ st.write("You have voted for all the images")
145
+ st.stop()
146
+
147
+ path = hfh.hf_hub_download(
148
+ repo_id="aifred-smart-life-coach/capstone-images",
149
+ repo_type="dataset",
150
+ filename=image_path,
151
+ token=os.environ.get("hf_token")
152
+ )
153
+ st.image(path, width=300)
154
+
155
+ with col2:
156
+ st.write(image_path)
157
+ gender = st.selectbox("Gender", [
158
+ "Male",
159
+ "Female",
160
+ "Non-defining",
161
+ ])
162
+ healthiness = st.slider("How healthy is this picture?", 0, 100, 50)
163
+ fat_level = st.slider("How fat is this picture?", 0, 100, 50)
164
+ muscle_level = st.slider("How muscular is this picture?", 0, 100, 50)
165
+ uuid_num = get_uuid()
166
+ submitted_second = st.form_submit_button("Submit")
167
 
168
  if submitted_second:
169
  update_vote(
 
176
  uuid_num=uuid_num,
177
  )
178
  with st.spinner("Wait for the upload of the vote", show_time=True):
179
+ time.sleep(1)
180
  st.rerun()
181
 
182
  st.success(f"Vote submitted uuid: {uuid_num} (in case you want to undo the vote)")