tokeron commited on
Commit
dbf6fc9
1 Parent(s): fe9c201

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -27
app.py CHANGED
@@ -8,40 +8,20 @@ from diffusion_lens import get_images
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
14
- yield all_images # Yield the list of all images
 
 
15
 
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
-
22
- # Bind the button click to the generate_images function
23
- # button.click(fn=generate_images, inputs=[text_input, gr.State(all_images)], outputs=gallery)
24
 
25
- text_input.submit(fn=generate_images, inputs=text_input, outputs=gallery)
 
26
 
27
  demo.launch()
28
 
29
-
30
- # def display_images(images):
31
- # # Prepare images for display
32
- # return [gr.Image(image) for image in images]
33
-
34
- # def get_prompt(prompt):
35
- # print('prompt:', prompt)
36
- # return prompt
37
-
38
- # def generate_images(prompt):
39
- # print('calling diffusion lens')
40
- # for skip_layers in range(23, 0, -1):
41
- # images = get_images(prompt, skip_layers=skip_layers)
42
- # yield images[0] # Yield each image as soon as it's ready
43
- # # yield gr.Image(images[0]) # Yield each image as soon as it's ready
44
-
45
- # with gr.Blocks() as demo:
46
- # text_input = gr.Interface(fn=generate_images, inputs="text", outputs="image")
47
- # demo.launch()
 
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
 
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