tokeron commited on
Commit
5da5f21
1 Parent(s): f6172f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -18
app.py CHANGED
@@ -1,31 +1,41 @@
1
  import gradio as gr
2
- import sys
3
- # sys.path.append("LaVi-Bridge/test")
4
- # from llama2_unet_diffusion_lens import call_diffusion_lens
5
  from diffusion_lens import get_images
6
- import gradio as gr
7
- import os
8
- import subprocess
9
-
10
-
11
 
12
- def display_images(images):
13
- # Prepare images for display
14
- return [gr.Image(image) for image in images]
15
 
16
- def get_prompt(prompt):
17
- print('prompt:', prompt)
18
- return prompt
19
 
20
 
21
 
22
  def generate_images(prompt):
23
  print('calling diffusion lens')
 
24
  for skip_layers in range(23, 0, -1):
25
  images = get_images(prompt, skip_layers=skip_layers)
26
- yield images[0] # Yield each image as soon as it's ready
27
- # yield gr.Image(images[0]) # Yield each image as soon as it's ready
28
 
29
  with gr.Blocks() as demo:
30
- text_input = gr.Interface(fn=generate_images, inputs="text", outputs="image")
31
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  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
  for skip_layers in range(23, 0, -1):
12
  images = get_images(prompt, skip_layers=skip_layers)
13
+ all_images.append(images[0]) # 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").style(grid=[2, 3], height='auto') # Adjust grid as needed
19
+ text_input.change(fn=generate_images, inputs=text_input, outputs=gallery)
20
+
21
+ demo.launch()
22
+
23
+
24
+ # def display_images(images):
25
+ # # Prepare images for display
26
+ # return [gr.Image(image) for image in images]
27
+
28
+ # def get_prompt(prompt):
29
+ # print('prompt:', prompt)
30
+ # return prompt
31
+
32
+ # def generate_images(prompt):
33
+ # print('calling diffusion lens')
34
+ # for skip_layers in range(23, 0, -1):
35
+ # images = get_images(prompt, skip_layers=skip_layers)
36
+ # yield images[0] # Yield each image as soon as it's ready
37
+ # # yield gr.Image(images[0]) # Yield each image as soon as it's ready
38
+
39
+ # with gr.Blocks() as demo:
40
+ # text_input = gr.Interface(fn=generate_images, inputs="text", outputs="image")
41
+ # demo.launch()