tokeron commited on
Commit
740a0ae
1 Parent(s): d721051

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -10
app.py CHANGED
@@ -2,26 +2,19 @@ import gradio as gr
2
  from diffusion_lens import get_images
3
 
4
 
5
-
6
-
7
-
8
  def generate_images(prompt):
9
  print('calling diffusion lens')
 
10
  all_images = [] # Initialize a list to store all images
11
- message = 'Generating images from intermediate layers..)' # Message for the user
12
  for skip_layers in range(11, -1, -1):
13
  images = get_images(prompt, skip_layers=skip_layers)
14
  all_images.append((images[0], f'layer_{12 - skip_layers}'))
15
- # all_images.append(images[0]) # (images[0], f'layer_{12 - skip_layers}')) # Add the new image to the list
16
- # yield all_images # Yield the list of all images
17
- yield all_images, message # Yield the list of all images with labels and the message
18
 
19
  with gr.Blocks() as demo:
20
  text_input = gr.Textbox(label="Enter prompt")
21
  gallery = gr.Gallery(label="Generated Images", columns=6, rows=2, object_fit="contain", height="auto")
22
- message_display = gr.Text(value='') # Component to display the message
23
- # text_input.submit(fn=generate_images, inputs=text_input, outputs=gallery)
24
- text_input.submit(fn=generate_images, inputs=text_input, outputs=[gallery, message_display])
25
 
26
  demo.launch()
27
 
 
2
  from diffusion_lens import get_images
3
 
4
 
 
 
 
5
  def generate_images(prompt):
6
  print('calling diffusion lens')
7
+ gr.Info('Generating images from intermediate layers..')
8
  all_images = [] # Initialize a list to store all images
 
9
  for skip_layers in range(11, -1, -1):
10
  images = get_images(prompt, skip_layers=skip_layers)
11
  all_images.append((images[0], f'layer_{12 - skip_layers}'))
12
+ yield all_images
 
 
13
 
14
  with gr.Blocks() as demo:
15
  text_input = gr.Textbox(label="Enter prompt")
16
  gallery = gr.Gallery(label="Generated Images", columns=6, rows=2, object_fit="contain", height="auto")
17
+ text_input.submit(fn=generate_images, inputs=text_input, outputs=gallery)
 
 
18
 
19
  demo.launch()
20