Spaces:
Sleeping
Sleeping
File size: 1,099 Bytes
2ec2ebd fe9c201 12ff912 c3eb335 dbf6fc9 ba74c9e ad4c6dc dbf6fc9 2ec2ebd e18f8f6 5da5f21 ba74c9e fe9c201 dbf6fc9 c3eb335 fe9c201 c3eb335 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import gradio as gr
from diffusion_lens import get_images
def generate_images(prompt):
print('calling diffusion lens')
all_images = [] # Initialize a list to store all images
message = 'Generating images from intermediate layers..)' # Message for the user
for skip_layers in range(11, -1, -1):
images = get_images(prompt, skip_layers=skip_layers)
all_images.append((images[0], f'layer_{12 - skip_layers}'))
# all_images.append(images[0]) # (images[0], f'layer_{12 - skip_layers}')) # Add the new image to the list
# yield all_images # Yield the list of all images
yield all_images, message # Yield the list of all images with labels and the message
with gr.Blocks() as demo:
text_input = gr.Textbox(label="Enter prompt")
gallery = gr.Gallery(label="Generated Images", columns=6, rows=2, object_fit="contain", height="auto")
# text_input.submit(fn=generate_images, inputs=text_input, outputs=gallery)
text_input.submit(fn=generate_images, inputs=text_input, outputs=[gallery, message_display])
demo.launch()
|