ChenyangSi commited on
Commit
bd26015
·
1 Parent(s): f7c4b88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -6,6 +6,13 @@ from diffusers import StableDiffusionPipeline
6
  from free_lunch_utils import register_free_upblock2d, register_free_crossattn_upblock2d
7
 
8
 
 
 
 
 
 
 
 
9
  torch.manual_seed(42)
10
  model_id = "CompVis/stable-diffusion-v1-4"
11
 
@@ -22,7 +29,7 @@ model_id = "CompVis/stable-diffusion-v1-4"
22
  pip = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
23
  pip = pip.to("cuda")
24
 
25
- def infer(prompt, seed, b1, b2, s1, s2):
26
 
27
  # pip = StableDiffusionPipeline.from_pretrained(model, torch_dtype=torch.float16)
28
  # pip = pip.to("cuda")
@@ -116,11 +123,11 @@ with block:
116
  sd_options = gr.Dropdown(["SD1.4", "SD1.5", "SD2.1"], label="SD options")
117
 
118
  if sd_options == 'SD1.5':
119
- model = "runwayml/stable-diffusion-v1-5"
120
  elif sd_options == 'SD2.1':
121
- model = "stabilityai/stable-diffusion-2-1"
122
  else:
123
- model = "CompVis/stable-diffusion-v1-4"
124
 
125
  # pip = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
126
  # pip = pip.to("cuda")
@@ -184,11 +191,11 @@ with block:
184
  image_2_label = gr.Markdown("FreeU")
185
 
186
 
187
- ex = gr.Examples(examples=examples, fn=infer, inputs=[text, seed, b1, b2, s1, s2], outputs=[image_1, image_2], cache_examples=False)
188
  ex.dataset.headers = [""]
189
 
190
- text.submit(infer, inputs=[text, seed, b1, b2, s1, s2], outputs=[image_1, image_2])
191
- btn.click(infer, inputs=[text, seed, b1, b2, s1, s2], outputs=[image_1, image_2])
192
 
193
  block.launch()
194
  # block.queue(default_enabled=False).launch(share=False)
 
6
  from free_lunch_utils import register_free_upblock2d, register_free_crossattn_upblock2d
7
 
8
 
9
+ # if sd_options == 'SD1.5':
10
+ # model = "runwayml/stable-diffusion-v1-5"
11
+ # elif sd_options == 'SD2.1':
12
+ # model = "stabilityai/stable-diffusion-2-1"
13
+ # else:
14
+ # model = "CompVis/stable-diffusion-v1-4"
15
+
16
  torch.manual_seed(42)
17
  model_id = "CompVis/stable-diffusion-v1-4"
18
 
 
29
  pip = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
30
  pip = pip.to("cuda")
31
 
32
+ def infer(prompt, sd_model, seed, b1, b2, s1, s2):
33
 
34
  # pip = StableDiffusionPipeline.from_pretrained(model, torch_dtype=torch.float16)
35
  # pip = pip.to("cuda")
 
123
  sd_options = gr.Dropdown(["SD1.4", "SD1.5", "SD2.1"], label="SD options")
124
 
125
  if sd_options == 'SD1.5':
126
+ sd_model = 1.5
127
  elif sd_options == 'SD2.1':
128
+ sd_model = 2.1
129
  else:
130
+ sd_model = 1.4
131
 
132
  # pip = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
133
  # pip = pip.to("cuda")
 
191
  image_2_label = gr.Markdown("FreeU")
192
 
193
 
194
+ ex = gr.Examples(examples=examples, fn=infer, inputs=[text, sd_model, seed, b1, b2, s1, s2], outputs=[image_1, image_2], cache_examples=False)
195
  ex.dataset.headers = [""]
196
 
197
+ text.submit(infer, inputs=[text, sd_model, seed, b1, b2, s1, s2], outputs=[image_1, image_2])
198
+ btn.click(infer, inputs=[text, sd_model, seed, b1, b2, s1, s2], outputs=[image_1, image_2])
199
 
200
  block.launch()
201
  # block.queue(default_enabled=False).launch(share=False)