Update app.py
Browse files
app.py
CHANGED
@@ -386,18 +386,19 @@ def add_custom_lora(custom_lora, selected_indices, current_loras, gallery, debug
|
|
386 |
image = download_file_mod(image)
|
387 |
except Exception as e:
|
388 |
logs = append_debug_log(f"Error downloading image: {e}", logs)
|
389 |
-
image =
|
390 |
|
391 |
existing_item_index = next((index for (index, item) in enumerate(current_loras) if item['repo'] == repo), None)
|
392 |
if existing_item_index is None:
|
393 |
-
|
394 |
-
"image": image or
|
395 |
"title": title,
|
396 |
"repo": repo,
|
397 |
"weights": path,
|
398 |
"trigger_word": trigger_word
|
399 |
-
}
|
400 |
-
|
|
|
401 |
|
402 |
gallery_items = [(item["image"], item["title"]) for item in current_loras]
|
403 |
return current_loras, gr.update(value=gallery_items), gr.update(value=logs)
|
@@ -405,12 +406,13 @@ def add_custom_lora(custom_lora, selected_indices, current_loras, gallery, debug
|
|
405 |
logs = append_debug_log("No custom LoRA provided.", logs)
|
406 |
return current_loras, gallery, gr.update(value=logs)
|
407 |
except Exception as e:
|
408 |
-
logs = append_debug_log(f"Error: {e}", logs)
|
409 |
return current_loras, gallery, gr.update(value=logs)
|
410 |
|
411 |
|
412 |
|
413 |
|
|
|
414 |
def update_gallery_with_loras(selected_indices, loras_state, gallery):
|
415 |
"""
|
416 |
Aktualisiert die Galerie basierend auf der Auswahl. Implementiert die Vorschau-Logik.
|
@@ -874,13 +876,12 @@ css = '''
|
|
874 |
'''
|
875 |
with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=css, delete_cache=(60, 3600)) as app:
|
876 |
|
877 |
-
# Debug-Log ganz oben hinzufügen
|
878 |
debug_log = gr.Textbox(
|
879 |
label="Debug Log",
|
880 |
interactive=False,
|
881 |
-
placeholder="Hier erscheinen Debug-Informationen...",
|
882 |
lines=10,
|
883 |
-
|
|
|
884 |
)
|
885 |
|
886 |
with gr.Tab("FLUX LoRA the Explorer"):
|
|
|
386 |
image = download_file_mod(image)
|
387 |
except Exception as e:
|
388 |
logs = append_debug_log(f"Error downloading image: {e}", logs)
|
389 |
+
image = get_custom_image() # Fallback verwenden
|
390 |
|
391 |
existing_item_index = next((index for (index, item) in enumerate(current_loras) if item['repo'] == repo), None)
|
392 |
if existing_item_index is None:
|
393 |
+
new_item = {
|
394 |
+
"image": image or get_custom_image(), # Fallback erneut prüfen
|
395 |
"title": title,
|
396 |
"repo": repo,
|
397 |
"weights": path,
|
398 |
"trigger_word": trigger_word
|
399 |
+
}
|
400 |
+
current_loras.append(new_item)
|
401 |
+
logs = append_debug_log(f"Added new LoRA: {title}", logs)
|
402 |
|
403 |
gallery_items = [(item["image"], item["title"]) for item in current_loras]
|
404 |
return current_loras, gr.update(value=gallery_items), gr.update(value=logs)
|
|
|
406 |
logs = append_debug_log("No custom LoRA provided.", logs)
|
407 |
return current_loras, gallery, gr.update(value=logs)
|
408 |
except Exception as e:
|
409 |
+
logs = append_debug_log(f"Error in add_custom_lora: {e}", logs)
|
410 |
return current_loras, gallery, gr.update(value=logs)
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
+
|
416 |
def update_gallery_with_loras(selected_indices, loras_state, gallery):
|
417 |
"""
|
418 |
Aktualisiert die Galerie basierend auf der Auswahl. Implementiert die Vorschau-Logik.
|
|
|
876 |
'''
|
877 |
with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=css, delete_cache=(60, 3600)) as app:
|
878 |
|
|
|
879 |
debug_log = gr.Textbox(
|
880 |
label="Debug Log",
|
881 |
interactive=False,
|
|
|
882 |
lines=10,
|
883 |
+
placeholder="Hier erscheinen Debug-Informationen...",
|
884 |
+
type="text" # Stelle sicher, dass sie nur Text akzeptiert
|
885 |
)
|
886 |
|
887 |
with gr.Tab("FLUX LoRA the Explorer"):
|