huzey commited on
Commit
8bdcc28
1 Parent(s): 4fa6c93
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1225,9 +1225,9 @@ def make_input_images_section(rows=1, cols=3, height="auto", advanced=False, is_
1225
  random_seed_slider = gr.Slider(0, 1000, step=1, label="Random seed", value=42, elem_id="random_seed", visible=True)
1226
 
1227
  # add functionality, save and load images to profile
1228
- with gr.Accordion("Saved Image Profiles", open=False) as profile_accordion:
1229
  with gr.Row():
1230
- profile_text = gr.Textbox(label="Profile name", placeholder="Type here: Profile name to save/load/delete", elem_id="profile-name", scale=6, show_label=False)
1231
  list_profiles_button = gr.Button("📋 List", elem_id="list-profile-button", variant='secondary', scale=3)
1232
  with gr.Row():
1233
  save_profile_button = gr.Button("💾 Save", elem_id="save-profile-button", variant='secondary')
@@ -1260,14 +1260,17 @@ def make_input_images_section(rows=1, cols=3, height="auto", advanced=False, is_
1260
  gr.Info(f"Profile {profile_name} saved.")
1261
  return profile_path
1262
 
1263
- def load_profile(self, profile_name):
1264
  profile_path = os.path.join(self.profile_dir, profile_name)
1265
  if not os.path.exists(profile_path):
1266
  raise gr.Error(f"Profile {profile_name} not found.")
1267
  with open(profile_path, "rb") as f:
1268
  images = pickle.load(f)
1269
  gr.Info(f"Profile {profile_name} loaded.")
1270
- return images
 
 
 
1271
 
1272
  def delete_profile(self, profile_name):
1273
  profile_path = os.path.join(self.profile_dir, profile_name)
@@ -1281,7 +1284,7 @@ def make_input_images_section(rows=1, cols=3, height="auto", advanced=False, is_
1281
  cache_dir = os.path.join(cache_dir, "demo_profiles")
1282
  on_disk_profiles = OnDiskProfiles(cache_dir)
1283
  save_profile_button.click(fn=lambda name, images: on_disk_profiles.save_profile(name, images), inputs=[profile_text, input_gallery])
1284
- load_profile_button.click(fn=lambda name: gr.update(value=on_disk_profiles.load_profile(name)), inputs=profile_text, outputs=[input_gallery])
1285
  delete_profile_button.click(fn=lambda name: on_disk_profiles.delete_profile(name), inputs=profile_text)
1286
  list_profiles_button.click(fn=lambda: gr.Info(on_disk_profiles.list_profiles(), duration=0))
1287
 
 
1225
  random_seed_slider = gr.Slider(0, 1000, step=1, label="Random seed", value=42, elem_id="random_seed", visible=True)
1226
 
1227
  # add functionality, save and load images to profile
1228
+ with gr.Accordion("Saved Image Profiles", open=True) as profile_accordion:
1229
  with gr.Row():
1230
+ profile_text = gr.Textbox(label="Profile name", placeholder="telecaster", elem_id="profile-name", scale=6, show_label=False)
1231
  list_profiles_button = gr.Button("📋 List", elem_id="list-profile-button", variant='secondary', scale=3)
1232
  with gr.Row():
1233
  save_profile_button = gr.Button("💾 Save", elem_id="save-profile-button", variant='secondary')
 
1260
  gr.Info(f"Profile {profile_name} saved.")
1261
  return profile_path
1262
 
1263
+ def load_profile(self, profile_name, existing_images):
1264
  profile_path = os.path.join(self.profile_dir, profile_name)
1265
  if not os.path.exists(profile_path):
1266
  raise gr.Error(f"Profile {profile_name} not found.")
1267
  with open(profile_path, "rb") as f:
1268
  images = pickle.load(f)
1269
  gr.Info(f"Profile {profile_name} loaded.")
1270
+ if existing_images is None:
1271
+ existing_images = []
1272
+
1273
+ return existing_images + images
1274
 
1275
  def delete_profile(self, profile_name):
1276
  profile_path = os.path.join(self.profile_dir, profile_name)
 
1284
  cache_dir = os.path.join(cache_dir, "demo_profiles")
1285
  on_disk_profiles = OnDiskProfiles(cache_dir)
1286
  save_profile_button.click(fn=lambda name, images: on_disk_profiles.save_profile(name, images), inputs=[profile_text, input_gallery])
1287
+ load_profile_button.click(fn=lambda name, existing_images: gr.update(value=on_disk_profiles.load_profile(name, existing_images)), inputs=[profile_text, input_gallery], outputs=[input_gallery])
1288
  delete_profile_button.click(fn=lambda name: on_disk_profiles.delete_profile(name), inputs=profile_text)
1289
  list_profiles_button.click(fn=lambda: gr.Info(on_disk_profiles.list_profiles(), duration=0))
1290