phyloforfun commited on
Commit
1f88809
1 Parent(s): 8d4eec7

file upload gallery

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -288,6 +288,7 @@ def save_uploaded_file(directory, img_file):
288
  def delete_directory(dir_path):
289
  try:
290
  shutil.rmtree(dir_path)
 
291
  st.success(f"Deleted previously uploaded images, making room for new images: {dir_path}")
292
  except OSError as e:
293
  st.error(f"Error: {dir_path} : {e.strerror}")
@@ -1091,10 +1092,8 @@ def content_tab_settings():
1091
  if uploaded_files:
1092
  # Clear input image gallery and input list
1093
  delete_directory(st.session_state['dir_uploaded_images'])
1094
- st.session_state['input_list'] = []
1095
  st.session_state['dir_uploaded_images'] = os.path.join(st.session_state.dir_home,'uploads')
1096
  validate_dir(st.session_state['dir_uploaded_images'])
1097
-
1098
  # Process the new iamges
1099
  for uploaded_file in uploaded_files:
1100
  print(uploaded_file)
@@ -1102,9 +1101,10 @@ def content_tab_settings():
1102
  save_uploaded_file(st.session_state['dir_uploaded_images'], uploaded_file)
1103
 
1104
  with col_local_2:
1105
- st.subheader('Image Gallery')
1106
- selected_img = image_select("Uploaded Images Ready for Transcription", st.session_state['input_list'], use_container_width=False)
1107
- st.button("Clear Staged Images",on_click=delete_directory, args=[st.session_state['dir_uploaded_images']])
 
1108
 
1109
  with col_cropped_1:
1110
  default_crops = st.session_state.config['leafmachine']['cropped_components'].get('save_cropped_annotations', ['leaf_whole'])
 
288
  def delete_directory(dir_path):
289
  try:
290
  shutil.rmtree(dir_path)
291
+ st.session_state['input_list'] = []
292
  st.success(f"Deleted previously uploaded images, making room for new images: {dir_path}")
293
  except OSError as e:
294
  st.error(f"Error: {dir_path} : {e.strerror}")
 
1092
  if uploaded_files:
1093
  # Clear input image gallery and input list
1094
  delete_directory(st.session_state['dir_uploaded_images'])
 
1095
  st.session_state['dir_uploaded_images'] = os.path.join(st.session_state.dir_home,'uploads')
1096
  validate_dir(st.session_state['dir_uploaded_images'])
 
1097
  # Process the new iamges
1098
  for uploaded_file in uploaded_files:
1099
  print(uploaded_file)
 
1101
  save_uploaded_file(st.session_state['dir_uploaded_images'], uploaded_file)
1102
 
1103
  with col_local_2:
1104
+ if st.session_state['input_list']:
1105
+ st.subheader('Image Gallery')
1106
+ selected_img = image_select("Uploaded Images Ready for Transcription", st.session_state['input_list'], use_container_width=False)
1107
+ st.button("Clear Staged Images",on_click=delete_directory, args=[st.session_state['dir_uploaded_images']])
1108
 
1109
  with col_cropped_1:
1110
  default_crops = st.session_state.config['leafmachine']['cropped_components'].get('save_cropped_annotations', ['leaf_whole'])