Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,7 +57,6 @@
|
|
| 57 |
# demo.launch()
|
| 58 |
|
| 59 |
|
| 60 |
-
|
| 61 |
import gradio as gr
|
| 62 |
import subprocess
|
| 63 |
import os
|
|
@@ -115,7 +114,7 @@ def save_image(image_filename):
|
|
| 115 |
def generate_and_display():
|
| 116 |
images, filenames = get_random_images()
|
| 117 |
save_buttons = [gr.Button("Save", elem_id=filename) for filename in filenames]
|
| 118 |
-
return images, save_buttons
|
| 119 |
|
| 120 |
def save_button_clicked(image_filename):
|
| 121 |
return save_image(image_filename)
|
|
@@ -126,9 +125,10 @@ with gr.Blocks() as demo:
|
|
| 126 |
output_gallery = gr.Gallery(label="Generated Designs", columns=5)
|
| 127 |
|
| 128 |
generate_button.click(fn=generate_and_display, outputs=[output_gallery, generate_button])
|
| 129 |
-
|
| 130 |
-
# Add save buttons for each image in the gallery
|
| 131 |
-
output_gallery.select(fn=save_button_clicked, inputs=output_gallery, outputs=None)
|
| 132 |
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
demo.launch()
|
|
|
|
| 57 |
# demo.launch()
|
| 58 |
|
| 59 |
|
|
|
|
| 60 |
import gradio as gr
|
| 61 |
import subprocess
|
| 62 |
import os
|
|
|
|
| 114 |
def generate_and_display():
|
| 115 |
images, filenames = get_random_images()
|
| 116 |
save_buttons = [gr.Button("Save", elem_id=filename) for filename in filenames]
|
| 117 |
+
return images, save_buttons, filenames
|
| 118 |
|
| 119 |
def save_button_clicked(image_filename):
|
| 120 |
return save_image(image_filename)
|
|
|
|
| 125 |
output_gallery = gr.Gallery(label="Generated Designs", columns=5)
|
| 126 |
|
| 127 |
generate_button.click(fn=generate_and_display, outputs=[output_gallery, generate_button])
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
+
# Create dynamic save buttons for each generated image
|
| 130 |
+
with gr.Row() as button_row:
|
| 131 |
+
for filename in []:
|
| 132 |
+
gr.Button("Save", elem_id=filename).click(fn=save_button_clicked, inputs=filename, outputs=None)
|
| 133 |
+
|
| 134 |
demo.launch()
|