Update app.py
Browse filesSDXL VAE is redundant on SDXL 0.9 and as far as I can tell, it makes images worse....
app.py
CHANGED
@@ -6,18 +6,16 @@ from PIL import Image
|
|
6 |
from diffusers import DiffusionPipeline
|
7 |
from huggingface_hub import login
|
8 |
import os
|
9 |
-
from diffusers.models import AutoencoderKL
|
10 |
|
11 |
login(token=os.environ.get('HF_KEY'))
|
12 |
|
13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
14 |
torch.cuda.max_memory_allocated(device='cuda')
|
15 |
-
vae = AutoencoderKL.from_pretrained("stabilityai/sdxl-vae", torch_dtype=torch.float16)
|
16 |
torch.cuda.empty_cache()
|
17 |
|
18 |
def genie (prompt, negative_prompt, height, width, scale, steps, seed, upscaler):
|
19 |
torch.cuda.max_memory_allocated(device='cuda')
|
20 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
|
21 |
pipe = pipe.to(device)
|
22 |
pipe.enable_xformers_memory_efficient_attention()
|
23 |
torch.cuda.empty_cache()
|
@@ -26,7 +24,7 @@ def genie (prompt, negative_prompt, height, width, scale, steps, seed, upscaler)
|
|
26 |
torch.cuda.empty_cache()
|
27 |
if upscaler == 'Yes':
|
28 |
torch.cuda.max_memory_allocated(device='cuda')
|
29 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
|
30 |
pipe = pipe.to(device)
|
31 |
pipe.enable_xformers_memory_efficient_attention()
|
32 |
image = pipe(prompt=prompt, image=int_image).images[0]
|
@@ -41,7 +39,7 @@ def genie (prompt, negative_prompt, height, width, scale, steps, seed, upscaler)
|
|
41 |
else:
|
42 |
torch.cuda.empty_cache()
|
43 |
torch.cuda.max_memory_allocated(device=device)
|
44 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
|
45 |
pipe = pipe.to(device)
|
46 |
pipe.enable_xformers_memory_efficient_attention()
|
47 |
image = pipe(prompt=prompt, image=int_image).images[0]
|
|
|
6 |
from diffusers import DiffusionPipeline
|
7 |
from huggingface_hub import login
|
8 |
import os
|
|
|
9 |
|
10 |
login(token=os.environ.get('HF_KEY'))
|
11 |
|
12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
13 |
torch.cuda.max_memory_allocated(device='cuda')
|
|
|
14 |
torch.cuda.empty_cache()
|
15 |
|
16 |
def genie (prompt, negative_prompt, height, width, scale, steps, seed, upscaler):
|
17 |
torch.cuda.max_memory_allocated(device='cuda')
|
18 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
19 |
pipe = pipe.to(device)
|
20 |
pipe.enable_xformers_memory_efficient_attention()
|
21 |
torch.cuda.empty_cache()
|
|
|
24 |
torch.cuda.empty_cache()
|
25 |
if upscaler == 'Yes':
|
26 |
torch.cuda.max_memory_allocated(device='cuda')
|
27 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
28 |
pipe = pipe.to(device)
|
29 |
pipe.enable_xformers_memory_efficient_attention()
|
30 |
image = pipe(prompt=prompt, image=int_image).images[0]
|
|
|
39 |
else:
|
40 |
torch.cuda.empty_cache()
|
41 |
torch.cuda.max_memory_allocated(device=device)
|
42 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
43 |
pipe = pipe.to(device)
|
44 |
pipe.enable_xformers_memory_efficient_attention()
|
45 |
image = pipe(prompt=prompt, image=int_image).images[0]
|