Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -61,18 +61,29 @@ last_cn_on = False
|
|
61 |
|
62 |
MAX_SEED = 2**32-1
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
75 |
|
|
|
76 |
with gr.Blocks() as app:
|
77 |
# Debug-Log-Feld hinzufügen
|
78 |
debug_log = gr.Textbox(
|
@@ -86,40 +97,32 @@ with gr.Blocks() as app:
|
|
86 |
# Test-Input-Feld und Button
|
87 |
with gr.Row():
|
88 |
test_input = gr.Textbox(
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
# Funktion zum Testen
|
95 |
-
def run_test(input_text, debug_log):
|
96 |
-
try:
|
97 |
-
# Eingabe auf bekannte Tests prüfen
|
98 |
-
if input_text == "get_custom_image":
|
99 |
-
result = get_custom_image()
|
100 |
-
else:
|
101 |
-
result = f"Unbekannter Test: {input_text}"
|
102 |
-
# Ergebnis ins Debug-Log schreiben
|
103 |
-
updated_log = debug_log + f"\nTest '{input_text}': {result}"
|
104 |
-
return updated_log
|
105 |
-
except Exception as e:
|
106 |
-
# Fehler ebenfalls ins Debug-Log schreiben
|
107 |
-
updated_log = debug_log + f"\nFehler beim Test '{input_text}': {str(e)}"
|
108 |
-
return updated_log
|
109 |
|
110 |
# Test-Button mit der Funktion verbinden
|
111 |
test_button.click(
|
112 |
-
run_test,
|
113 |
inputs=[test_input, debug_log],
|
114 |
outputs=debug_log
|
115 |
)
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
-
# Hilfsfunktion zum Anhängen von Logs
|
119 |
-
def append_debug_log(log_text, current_logs=""):
|
120 |
-
"""Fügt einen neuen Log-Eintrag hinzu."""
|
121 |
-
updated_logs = current_logs + f"\n{log_text}"
|
122 |
-
return updated_logs
|
123 |
|
124 |
|
125 |
def unload_lora():
|
|
|
61 |
|
62 |
MAX_SEED = 2**32-1
|
63 |
|
64 |
+
# Funktion für Tests
|
65 |
+
def run_test(input_text, debug_log):
|
66 |
+
try:
|
67 |
+
# Eingabe auf bekannte Tests prüfen
|
68 |
+
if input_text == "get_custom_image":
|
69 |
+
result = get_custom_image()
|
70 |
+
else:
|
71 |
+
result = f"Unbekannter Test: {input_text}"
|
72 |
+
# Ergebnis ins Debug-Log schreiben
|
73 |
+
updated_log = debug_log + f"\nTest '{input_text}': {result}"
|
74 |
+
return updated_log
|
75 |
+
except Exception as e:
|
76 |
+
# Fehler ebenfalls ins Debug-Log schreiben
|
77 |
+
updated_log = debug_log + f"\nFehler beim Test '{input_text}': {str(e)}"
|
78 |
+
return updated_log
|
79 |
|
80 |
+
# Hilfsfunktion zum Anhängen von Logs
|
81 |
+
def append_debug_log(log_text, current_logs=""):
|
82 |
+
"""Fügt einen neuen Log-Eintrag hinzu."""
|
83 |
+
updated_logs = current_logs + f"\n{log_text}"
|
84 |
+
return updated_logs
|
85 |
|
86 |
+
# Gradio Blocks definieren
|
87 |
with gr.Blocks() as app:
|
88 |
# Debug-Log-Feld hinzufügen
|
89 |
debug_log = gr.Textbox(
|
|
|
97 |
# Test-Input-Feld und Button
|
98 |
with gr.Row():
|
99 |
test_input = gr.Textbox(
|
100 |
+
label="Test Input",
|
101 |
+
placeholder="Gib den Namen einer Funktion ein, z.B. 'get_custom_image'.",
|
102 |
+
)
|
103 |
+
test_button = gr.Button("Run Test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
# Test-Button mit der Funktion verbinden
|
106 |
test_button.click(
|
107 |
+
fn=run_test,
|
108 |
inputs=[test_input, debug_log],
|
109 |
outputs=debug_log
|
110 |
)
|
111 |
|
112 |
+
# Ein Beispiel-Funktionalität: Dummy-Echo
|
113 |
+
with gr.Row():
|
114 |
+
input_box = gr.Textbox(label="Input")
|
115 |
+
output_box = gr.Textbox(label="Output")
|
116 |
+
dummy_button = gr.Button("Dummy Test")
|
117 |
+
|
118 |
+
def dummy_function(text):
|
119 |
+
return f"Echo: {text}"
|
120 |
+
|
121 |
+
dummy_button.click(dummy_function, inputs=[input_box], outputs=[output_box])
|
122 |
+
|
123 |
+
# App starten
|
124 |
+
app.launch()
|
125 |
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
|
128 |
def unload_lora():
|