ChenyangSi commited on
Commit
c331654
·
1 Parent(s): 1e8d7dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
app.py CHANGED
@@ -30,33 +30,35 @@ model_id = "CompVis/stable-diffusion-v1-4"
30
  pip_1_4 = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
31
  pip_1_4 = pip_1_4.to("cuda")
32
 
33
- # model_id = "runwayml/stable-diffusion-v1-5"
34
- # pip_1_5 = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
35
- # pip_1_5 = pip_1_5.to("cuda")
36
-
37
- # model_id = "stabilityai/stable-diffusion-2-1"
38
- # pip_2_1 = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
39
- # pip_2_1 = pip_2_1.to("cuda")
40
-
41
- def infer(prompt, sd, seed, b1, b2, s1, s2):
42
-
43
- # pip = StableDiffusionPipeline.from_pretrained(model, torch_dtype=torch.float16)
44
- # pip = pip.to("cuda")
45
-
46
-
 
 
47
  # register_free_upblock2d(pip, b1=1.0, b2=1.0, s1=1.0, s2=1.0)
48
  # register_free_crossattn_upblock2d(pip, b1=1.0, b2=1.0, s1=1.0, s2=1.0)
49
 
50
  torch.manual_seed(seed)
51
  print("Generating SD:")
52
- sd_image = pip_1_4(prompt).images[0]
53
 
54
  # register_free_upblock2d(pip, b1=b1, b2=b2, s1=s1, s2=s1)
55
  # register_free_crossattn_upblock2d(pip, b1=b1, b2=b2, s1=s1, s2=s1)
56
 
57
  torch.manual_seed(seed)
58
  print("Generating FreeU:")
59
- freeu_image = pip_1_4(prompt).images[0]
60
 
61
  # First SD, then freeu
62
  images = [sd_image, freeu_image]
 
30
  pip_1_4 = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
31
  pip_1_4 = pip_1_4.to("cuda")
32
 
33
+ model_id = "runwayml/stable-diffusion-v1-5"
34
+ pip_1_5 = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
35
+ pip_1_5 = pip_1_5.to("cuda")
36
+
37
+ model_id = "stabilityai/stable-diffusion-2-1"
38
+ pip_2_1 = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
39
+ pip_2_1 = pip_2_1.to("cuda")
40
+
41
+ def infer(prompt, sd_options, seed, b1, b2, s1, s2):
42
+
43
+ if sd_options == 'SD1.5':
44
+ pip = pip_1_5
45
+ elif sd_options == 'SD2.1':
46
+ pip = pip_2_1
47
+ else:
48
+ pip = pip_1_4
49
  # register_free_upblock2d(pip, b1=1.0, b2=1.0, s1=1.0, s2=1.0)
50
  # register_free_crossattn_upblock2d(pip, b1=1.0, b2=1.0, s1=1.0, s2=1.0)
51
 
52
  torch.manual_seed(seed)
53
  print("Generating SD:")
54
+ sd_image = pip(prompt, num_inference_steps=25).images[0]
55
 
56
  # register_free_upblock2d(pip, b1=b1, b2=b2, s1=s1, s2=s1)
57
  # register_free_crossattn_upblock2d(pip, b1=b1, b2=b2, s1=s1, s2=s1)
58
 
59
  torch.manual_seed(seed)
60
  print("Generating FreeU:")
61
+ freeu_image = pip(prompt, num_inference_steps=25).images[0]
62
 
63
  # First SD, then freeu
64
  images = [sd_image, freeu_image]