Spaces:
Running
Running
Sean Powell commited on
Commit ·
62c63fc
1
Parent(s): ecf35ff
Adjust parameters to address render issues.
Browse files- Disable tiling on the first pass to produce less dense patterns.
- Increase inference steps to 50 to generate higher quality / higher variety images.
- Increase guidance scale to generate higher variety images.
- Decrease img2img strength to 0.3 to ensure the img2img pass tiles effectively.
- handler.py +5 -4
- utils/pipes.py +4 -3
handler.py
CHANGED
|
@@ -6,13 +6,14 @@ import torch
|
|
| 6 |
from utils import pipes, tiling, wallpaper, images
|
| 7 |
|
| 8 |
desired_output_width = 1024
|
| 9 |
-
inference_steps =
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
class EndpointHandler:
|
| 14 |
def __init__(self, path=""):
|
| 15 |
-
self.sdxl_pipe = pipes.create_stable_diffusion_xl_pipeline("cuda:0")
|
| 16 |
self.sdxl_img2img_pipe = pipes.create_stable_diffusion_xl_img2img_pipe("cuda:1")
|
| 17 |
print("post __init__ memory summary")
|
| 18 |
print(torch.cuda.memory_summary())
|
|
@@ -29,7 +30,7 @@ class EndpointHandler:
|
|
| 29 |
original_image_size = tiling.compute_input_tile_width_for_desired_output(desired_output_width)
|
| 30 |
|
| 31 |
original_image = self.sdxl_pipe(prompt=prompt, num_inference_steps=inference_steps, width=original_image_size,
|
| 32 |
-
height=original_image_size).images[0]
|
| 33 |
print("post-SDXL memory summary")
|
| 34 |
print(torch.cuda.memory_summary())
|
| 35 |
inner_rotated_tile = images.extract_inner_rotated_tile_from_image(original_image)
|
|
|
|
| 6 |
from utils import pipes, tiling, wallpaper, images
|
| 7 |
|
| 8 |
desired_output_width = 1024
|
| 9 |
+
inference_steps = 50
|
| 10 |
+
guidance_scale = 10
|
| 11 |
+
img2img_strength = 0.3
|
| 12 |
|
| 13 |
|
| 14 |
class EndpointHandler:
|
| 15 |
def __init__(self, path=""):
|
| 16 |
+
self.sdxl_pipe = pipes.create_stable_diffusion_xl_pipeline("cuda:0", enable_tiling=False)
|
| 17 |
self.sdxl_img2img_pipe = pipes.create_stable_diffusion_xl_img2img_pipe("cuda:1")
|
| 18 |
print("post __init__ memory summary")
|
| 19 |
print(torch.cuda.memory_summary())
|
|
|
|
| 30 |
original_image_size = tiling.compute_input_tile_width_for_desired_output(desired_output_width)
|
| 31 |
|
| 32 |
original_image = self.sdxl_pipe(prompt=prompt, num_inference_steps=inference_steps, width=original_image_size,
|
| 33 |
+
height=original_image_size, guidance_scale=guidance_scale).images[0]
|
| 34 |
print("post-SDXL memory summary")
|
| 35 |
print(torch.cuda.memory_summary())
|
| 36 |
inner_rotated_tile = images.extract_inner_rotated_tile_from_image(original_image)
|
utils/pipes.py
CHANGED
|
@@ -5,14 +5,15 @@ from diffusers import StableDiffusionXLImg2ImgPipeline, StableDiffusionXLPipelin
|
|
| 5 |
from utils import tiling
|
| 6 |
|
| 7 |
|
| 8 |
-
def create_stable_diffusion_xl_pipeline(device):
|
| 9 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
| 10 |
pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 11 |
"stabilityai/stable-diffusion-xl-base-1.0", vae=vae, torch_dtype=torch.float16, variant="fp16",
|
| 12 |
use_safetensors=True
|
| 13 |
)
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 16 |
pipe = pipe.to(device)
|
| 17 |
return pipe
|
| 18 |
|
|
|
|
| 5 |
from utils import tiling
|
| 6 |
|
| 7 |
|
| 8 |
+
def create_stable_diffusion_xl_pipeline(device, enable_tiling=True):
|
| 9 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
| 10 |
pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 11 |
"stabilityai/stable-diffusion-xl-base-1.0", vae=vae, torch_dtype=torch.float16, variant="fp16",
|
| 12 |
use_safetensors=True
|
| 13 |
)
|
| 14 |
+
if enable_tiling:
|
| 15 |
+
pipe.vae.disable_tiling()
|
| 16 |
+
tiling.enable_circular_tiling([pipe.vae, pipe.text_encoder, pipe.unet])
|
| 17 |
pipe = pipe.to(device)
|
| 18 |
return pipe
|
| 19 |
|