Ricercar commited on
Commit
06dc81a
·
1 Parent(s): bca2bcb

fix selection count

Browse files
Files changed (1) hide show
  1. pages/1_🖼️_Gallery.py +6 -3
pages/1_🖼️_Gallery.py CHANGED
@@ -67,7 +67,10 @@ class GalleryApp:
67
  # show checkbox
68
  checked = st.checkbox('Select', key=f'select_{idx + j}', value=check_init)
69
  if checked:
70
- st.session_state.selected_dict[prompt_id] = st.session_state.selected_dict.get(prompt_id, []) + [modelVersion_id]
 
 
 
71
  else:
72
  try:
73
  st.session_state.selected_dict[prompt_id].remove(modelVersion_id)
@@ -337,12 +340,12 @@ if __name__ == "__main__":
337
  switch_page("home")
338
  else:
339
  st.write('You have already logged in as ' + st.session_state.user_id[0])
340
- roster, promptBook, st.session_state["images_ds"] = load_hf_dataset()
341
  # print(promptBook.columns)
342
 
343
  # initialize selected_dict
344
  if 'selected_dict' not in st.session_state:
345
  st.session_state['selected_dict'] = {}
346
 
347
- app = GalleryApp(promptBook=promptBook, images_ds=st.session_state.images_ds)
348
  app.app()
 
67
  # show checkbox
68
  checked = st.checkbox('Select', key=f'select_{idx + j}', value=check_init)
69
  if checked:
70
+ if prompt_id not in st.session_state.selected_dict:
71
+ st.session_state.selected_dict[prompt_id] = []
72
+ if modelVersion_id not in st.session_state.selected_dict[prompt_id]:
73
+ st.session_state.selected_dict[prompt_id].append(modelVersion_id)
74
  else:
75
  try:
76
  st.session_state.selected_dict[prompt_id].remove(modelVersion_id)
 
340
  switch_page("home")
341
  else:
342
  st.write('You have already logged in as ' + st.session_state.user_id[0])
343
+ roster, promptBook, images_ds = load_hf_dataset()
344
  # print(promptBook.columns)
345
 
346
  # initialize selected_dict
347
  if 'selected_dict' not in st.session_state:
348
  st.session_state['selected_dict'] = {}
349
 
350
+ app = GalleryApp(promptBook=promptBook, images_ds=images_ds)
351
  app.app()