Spaces:
Runtime error
Runtime error
Commit
·
c331654
1
Parent(s):
1e8d7dc
Update app.py
Browse files
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 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
def infer(prompt,
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 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 =
|
| 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 =
|
| 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]
|