tokeron commited on
Commit
dcdc468
1 Parent(s): 6a0b597

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -37,6 +37,11 @@ model_num_of_layers = {
37
  'Stable Diffusion 2.1': 22,
38
  }
39
 
 
 
 
 
 
40
  def generate_images(prompt, model, seed):
41
  seed = random.randint(0, MAX_SEED) if seed == -1 else seed
42
  print('calling diffusion lens with model:', model, 'and seed:', seed)
@@ -46,7 +51,7 @@ def generate_images(prompt, model, seed):
46
  for skip_layers in range(max_num_of_layers - 1, -1, -1):
47
  # Pass the model and seed to the get_images function
48
  images = get_images(prompt, skip_layers=skip_layers, model=model, seed=seed)
49
- all_images.append((images[0], f'layer_{12 - skip_layers}'))
50
  yield all_images
51
 
52
  with gr.Blocks() as demo:
@@ -93,9 +98,9 @@ with gr.Blocks() as demo:
93
 
94
 
95
  generate_button = gr.Button("Generate Image")
96
-
97
  with gr.Column():
98
- gallery = gr.Gallery(label="Generated Images", columns=4, rows=3, object_fit="contain", height="auto")
99
 
100
  outputs = [gallery]
101
 
 
37
  'Stable Diffusion 2.1': 22,
38
  }
39
 
40
+ num_rows_dict = {
41
+ 'Stable Diffusion 1.4': 2,
42
+ 'Stable Diffusion 2.1': 4,
43
+ }
44
+
45
  def generate_images(prompt, model, seed):
46
  seed = random.randint(0, MAX_SEED) if seed == -1 else seed
47
  print('calling diffusion lens with model:', model, 'and seed:', seed)
 
51
  for skip_layers in range(max_num_of_layers - 1, -1, -1):
52
  # Pass the model and seed to the get_images function
53
  images = get_images(prompt, skip_layers=skip_layers, model=model, seed=seed)
54
+ all_images.append((images[0], f'layer_{max_num_of_layers - skip_layers}'))
55
  yield all_images
56
 
57
  with gr.Blocks() as demo:
 
98
 
99
 
100
  generate_button = gr.Button("Generate Image")
101
+ num_rows = num_rows_dict[model]
102
  with gr.Column():
103
+ gallery = gr.Gallery(label="Generated Images", columns=6, rows=num_rows, object_fit="contain", height="auto")
104
 
105
  outputs = [gallery]
106