Spaces:
Runtime error
Runtime error
user initials toggleable
Browse files
app.py
CHANGED
|
@@ -54,8 +54,14 @@ try:
|
|
| 54 |
except Exception as e:
|
| 55 |
print(e)
|
| 56 |
|
| 57 |
-
image_paths_global = []
|
|
|
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
def generate_images_wrapper(prompts, pw, model, show_labels):
|
| 61 |
global image_paths_global, image_labels_global
|
|
@@ -168,6 +174,8 @@ with gr.Blocks() as demo:
|
|
| 168 |
# btn.click(fn=generate_images_wrapper, inputs=[text, pw, model], outputs=output_images, api_name=False)
|
| 169 |
btn.click(fn=generate_images_wrapper, inputs=[text, pw, model, show_labels], outputs=output_images, api_name=False)
|
| 170 |
|
|
|
|
|
|
|
| 171 |
download_all_btn = gr.Button("Download All")
|
| 172 |
download_link = gr.File(label="Download Zip")
|
| 173 |
download_all_btn.click(fn=download_all_images, inputs=[], outputs=download_link)
|
|
|
|
| 54 |
except Exception as e:
|
| 55 |
print(e)
|
| 56 |
|
| 57 |
+
# image_paths_global = []
|
| 58 |
+
# image_labels_global = []
|
| 59 |
|
| 60 |
+
def update_labels(show_labels):
|
| 61 |
+
if show_labels:
|
| 62 |
+
return [(path, label) for path, label in zip(image_paths_global, image_labels_global)]
|
| 63 |
+
else:
|
| 64 |
+
return [(path, "") for path in image_paths_global] # Empty string as label to hide them
|
| 65 |
|
| 66 |
def generate_images_wrapper(prompts, pw, model, show_labels):
|
| 67 |
global image_paths_global, image_labels_global
|
|
|
|
| 174 |
# btn.click(fn=generate_images_wrapper, inputs=[text, pw, model], outputs=output_images, api_name=False)
|
| 175 |
btn.click(fn=generate_images_wrapper, inputs=[text, pw, model, show_labels], outputs=output_images, api_name=False)
|
| 176 |
|
| 177 |
+
show_labels.change(fn=update_labels, inputs=[show_labels], outputs=[output_images])
|
| 178 |
+
|
| 179 |
download_all_btn = gr.Button("Download All")
|
| 180 |
download_link = gr.File(label="Download Zip")
|
| 181 |
download_all_btn.click(fn=download_all_images, inputs=[], outputs=download_link)
|