macgaga commited on
Commit
8def086
·
verified ·
1 Parent(s): aab47c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -2
app.py CHANGED
@@ -358,7 +358,7 @@ def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
358
  current_loras.append(new_item)
359
 
360
  # Galerie-Elemente aktualisieren
361
- gallery_items = [(item["image"], item["title"]) for item in current_loras]
362
 
363
  # Auswahl-Indizes aktualisieren
364
  if len(selected_indices) < 2:
@@ -389,7 +389,36 @@ def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
389
  gr.update(value=gallery_items),
390
  selected_info_1,
391
  selected_info_2,
392
- sele
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
393
 
394
 
395
 
 
358
  current_loras.append(new_item)
359
 
360
  # Galerie-Elemente aktualisieren
361
+ gallery_items = update_gallery_with_loras(current_loras)
362
 
363
  # Auswahl-Indizes aktualisieren
364
  if len(selected_indices) < 2:
 
389
  gr.update(value=gallery_items),
390
  selected_info_1,
391
  selected_info_2,
392
+ selected_indices,
393
+ lora_scale_1,
394
+ lora_scale_2,
395
+ lora_image_1,
396
+ lora_image_2
397
+ )
398
+ except Exception as e:
399
+ print(f"Fehler beim Hinzufügen der benutzerdefinierten LoRA: {e}")
400
+ return current_loras, gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), gr.update(), gr.update()
401
+ else:
402
+ return current_loras, gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), gr.update(), gr.update()
403
+
404
+
405
+
406
+ def update_gallery_with_loras(loras):
407
+ """
408
+ Aktualisiert die Galerie mit den aktuellen LoRAs, auch bei fehlerhaften Einträgen.
409
+ """
410
+ gallery_items = []
411
+ for lora in loras:
412
+ try:
413
+ image = lora.get("image", "/path/to/default-placeholder.png")
414
+ title = lora.get("title", "Unknown LoRA")
415
+ gallery_items.append((image, title))
416
+ except Exception as e:
417
+ print(f"Fehler bei der Aktualisierung der Galerie: {e}")
418
+ gallery_items.append(("/path/to/default-placeholder.png", "Invalid LoRA Entry"))
419
+ return gallery_items
420
+
421
+
422
 
423
 
424