Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,9 @@ from diffusion_lens import get_images
|
|
5 |
|
6 |
|
7 |
|
8 |
-
def generate_images(prompt):
|
9 |
print('calling diffusion lens')
|
10 |
-
all_images = [] # Initialize a list to store all images
|
11 |
for skip_layers in range(11, -1, -1):
|
12 |
images = get_images(prompt, skip_layers=skip_layers)
|
13 |
all_images.append(images[0]) # (images[0], f'layer_{12 - skip_layers}')) # Add the new image to the list
|
@@ -16,6 +16,13 @@ def generate_images(prompt):
|
|
16 |
with gr.Blocks() as demo:
|
17 |
text_input = gr.Textbox(label="Enter prompt")
|
18 |
gallery = gr.Gallery(label="Generated Images", columns=6, rows=2, object_fit="contain", height="auto")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
text_input.change(fn=generate_images, inputs=text_input, outputs=gallery)
|
20 |
|
21 |
demo.launch()
|
|
|
5 |
|
6 |
|
7 |
|
8 |
+
def generate_images(prompt, all_images):
|
9 |
print('calling diffusion lens')
|
10 |
+
# all_images = [] # Initialize a list to store all images
|
11 |
for skip_layers in range(11, -1, -1):
|
12 |
images = get_images(prompt, skip_layers=skip_layers)
|
13 |
all_images.append(images[0]) # (images[0], f'layer_{12 - skip_layers}')) # Add the new image to the list
|
|
|
16 |
with gr.Blocks() as demo:
|
17 |
text_input = gr.Textbox(label="Enter prompt")
|
18 |
gallery = gr.Gallery(label="Generated Images", columns=6, rows=2, object_fit="contain", height="auto")
|
19 |
+
|
20 |
+
button = gr.Button("Diffusion Lens") # Create a button with the label 'Diffusion Lens'
|
21 |
+
all_images = [] # Initialize a list to store all images outside the function
|
22 |
+
|
23 |
+
# Bind the button click to the generate_images function
|
24 |
+
button.click(fn=generate_images, inputs=[text_input, gr.State(all_images)], outputs=gallery)
|
25 |
+
|
26 |
text_input.change(fn=generate_images, inputs=text_input, outputs=gallery)
|
27 |
|
28 |
demo.launch()
|