macgaga commited on
Commit
db5199c
·
verified ·
1 Parent(s): de63239

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -8
app.py CHANGED
@@ -27,6 +27,8 @@ from modutils import (search_civitai_lora, select_civitai_lora, search_civitai_l
27
  from tagger.tagger import predict_tags_wd, compose_prompt_to_copy
28
  from tagger.fl2flux import predict_tags_fl2_flux
29
 
 
 
30
  #Load prompts for randomization
31
  df = pd.read_csv('prompts.csv', header=None)
32
  prompt_values = df.values.flatten()
@@ -62,6 +64,30 @@ MAX_SEED = 2**32-1
62
  # Debug-Log-Feld hinzufügen
63
  debug_log = gr.Textbox(label="Debug Log", interactive=False, placeholder="Logs erscheinen hier...", lines=15)
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  # Hilfsfunktion zum Anhängen von Logs
66
  def append_debug_log(log_text, current_logs=""):
67
  """Fügt einen neuen Log-Eintrag hinzu."""
@@ -446,16 +472,18 @@ def get_custom_image():
446
  Liefert ein Bild für den Fallback.
447
  Prüft zuerst das Repository, dann die URL, und setzt sonst ein Platzhalterbild.
448
  """
 
 
449
  try:
450
- # Prüfen, ob ein benutzerdefiniertes Bild hochgeladen wurde
451
- # Platzhalter: "/path/to/default-placeholder.png"
452
- placeholder = "/path/to/default-placeholder.png"
453
- # Logik für benutzerdefiniertes Bild hinzufügen
454
- return placeholder
455
  except Exception as e:
456
- print(f"Error fetching custom image: {e}")
457
- return "/path/to/default-placeholder.png" # Sicherer Fallback
458
-
459
 
460
 
461
  def remove_custom_lora(selected_indices, current_loras, gallery):
@@ -884,6 +912,15 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=css, delete_ca
884
  type="text" # Stelle sicher, dass sie nur Text akzeptiert
885
  )
886
 
 
 
 
 
 
 
 
 
 
887
  with gr.Tab("FLUX LoRA the Explorer"):
888
  title = gr.HTML(
889
  """<h1><img src="https://huggingface.co/spaces/John6666/flux-lora-the-explorer/resolve/main/flux_lora.png" alt="LoRA">FLUX LoRA Explorer Mod Reloaded</h1>""",
 
27
  from tagger.tagger import predict_tags_wd, compose_prompt_to_copy
28
  from tagger.fl2flux import predict_tags_fl2_flux
29
 
30
+ CUSTOM_PLACEHOLDER = os.path.join(os.getcwd(), "custom.png")
31
+
32
  #Load prompts for randomization
33
  df = pd.read_csv('prompts.csv', header=None)
34
  prompt_values = df.values.flatten()
 
64
  # Debug-Log-Feld hinzufügen
65
  debug_log = gr.Textbox(label="Debug Log", interactive=False, placeholder="Logs erscheinen hier...", lines=15)
66
 
67
+ # Funktion, um Tests auszuführen
68
+ def run_test(input_text, debug_log):
69
+ try:
70
+ # Eingabe auf bekannte Tests prüfen
71
+ if input_text == "get_custom_image":
72
+ result = get_custom_image()
73
+ else:
74
+ result = f"Unbekannter Test: {input_text}"
75
+ # Ergebnis ins Debug-Log schreiben
76
+ updated_log = debug_log + f"\nTest '{input_text}': {result}"
77
+ return updated_log
78
+ except Exception as e:
79
+ # Fehler ebenfalls ins Debug-Log schreiben
80
+ updated_log = debug_log + f"\nFehler beim Test '{input_text}': {str(e)}"
81
+ return updated_log
82
+
83
+ # Test-Button mit der Funktion verbinden
84
+ test_button.click(
85
+ run_test,
86
+ inputs=[test_input, debug_log],
87
+ outputs=debug_log,
88
+ )
89
+
90
+
91
  # Hilfsfunktion zum Anhängen von Logs
92
  def append_debug_log(log_text, current_logs=""):
93
  """Fügt einen neuen Log-Eintrag hinzu."""
 
472
  Liefert ein Bild für den Fallback.
473
  Prüft zuerst das Repository, dann die URL, und setzt sonst ein Platzhalterbild.
474
  """
475
+ placeholder_path = "custom.png" # Pfad zum Platzhalterbild im Hauptverzeichnis
476
+
477
  try:
478
+ # Prüfen, ob das Platzhalterbild existiert
479
+ if os.path.exists(placeholder_path):
480
+ return placeholder_path
481
+ else:
482
+ raise FileNotFoundError(f"Platzhalterbild nicht gefunden: {placeholder_path}")
483
  except Exception as e:
484
+ print(f"Error in get_custom_image: {e}")
485
+ # Sicherer Fallback, falls das Platzhalterbild fehlt
486
+ return "/path/to/default-placeholder.png"
487
 
488
 
489
  def remove_custom_lora(selected_indices, current_loras, gallery):
 
912
  type="text" # Stelle sicher, dass sie nur Text akzeptiert
913
  )
914
 
915
+ # Test-Input-Feld und Button
916
+ with gr.Row():
917
+ test_input = gr.Textbox(
918
+ label="Test Input",
919
+ placeholder="Gib den Namen einer Funktion ein, z.B. 'get_custom_image'.",
920
+ )
921
+ test_button = gr.Button("Run Test")
922
+
923
+
924
  with gr.Tab("FLUX LoRA the Explorer"):
925
  title = gr.HTML(
926
  """<h1><img src="https://huggingface.co/spaces/John6666/flux-lora-the-explorer/resolve/main/flux_lora.png" alt="LoRA">FLUX LoRA Explorer Mod Reloaded</h1>""",