Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -160,12 +160,26 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=CSS) as demo:
|
|
160 |
with gr.Column(scale=2):
|
161 |
gallery2 = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery", interactive=False, show_share_button=True, format="png", preview=True, object_fit="cover", columns=2, rows=2)
|
162 |
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
gr.Markdown("")
|
171 |
demo.launch(show_api=False, max_threads=400)
|
|
|
160 |
with gr.Column(scale=2):
|
161 |
gallery2 = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery", interactive=False, show_share_button=True, format="png", preview=True, object_fit="cover", columns=2, rows=2)
|
162 |
|
163 |
+
for i, o in enumerate(output2):
|
164 |
+
# Change visibility based on num_images
|
165 |
+
num_images.change(
|
166 |
+
lambda num_images, i=i: gr.update(visible=(i < num_images)), # `i` corresponds to the index of the image
|
167 |
+
[num_images], # Only num_images needs to be an input
|
168 |
+
o, # Outputs the updated visibility of the image `o`
|
169 |
+
queue=False
|
170 |
+
)
|
171 |
+
|
172 |
+
# Image generation function
|
173 |
+
gen_event2 = gr.on(
|
174 |
+
triggers=[gen_button2.click, txt_input2.submit],
|
175 |
+
fn=gen_fn,
|
176 |
+
inputs=[i, num_images, model_choice2, txt_input2, neg_input2, height, width, steps, cfg, seed],
|
177 |
+
outputs=[o]
|
178 |
+
)
|
179 |
+
|
180 |
+
# Update gallery when a new image is generated
|
181 |
+
o.change(add_gallery, [o, model_choice2, gallery2], [gallery2])
|
182 |
+
|
183 |
|
184 |
gr.Markdown("")
|
185 |
demo.launch(show_api=False, max_threads=400)
|