From c36d5e66b8c308aaaa4200942c5af6b8135ce6a7 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Thu, 7 May 2026 10:45:03 +0200 Subject: [PATCH] auto-git: [change] generate_equirect.py --- generate_equirect.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/generate_equirect.py b/generate_equirect.py index 2f690ea..80c5175 100644 --- a/generate_equirect.py +++ b/generate_equirect.py @@ -358,6 +358,7 @@ def generate( ).to(device) base_pipe.unet = unet gen_pipe = base_pipe + del base_pipe, unet else: gen_pipe = StableDiffusionXLPipeline.from_pretrained( model_path, @@ -440,8 +441,12 @@ def generate( "Try one of: euler, euler_a, heun, ddim, dpmsolver, dpmsolver-sde." ) gen_pipe.enable_attention_slicing() - if is_sdxl and vae is not None and hasattr(gen_pipe, "enable_vae_tiling"): + if hasattr(gen_pipe, "enable_vae_tiling"): gen_pipe.enable_vae_tiling() + if hasattr(gen_pipe, "enable_vae_slicing"): + gen_pipe.enable_vae_slicing() + if "pipe_kwargs" in locals(): + del pipe_kwargs def progress_cb(phase: str, current: int, total: int): payload = { @@ -463,7 +468,19 @@ def generate( height=height, callback_steps=1, callback=lambda step, timestep, kwargs: progress_cb("gen", step + 1, steps), - ).images[0] + output_type="latent", + ) + latents = latent_output.images.detach().cpu() + decoder_vae = gen_pipe.vae + vae = None + del latent_output, gen_pipe + clear_torch_cache(device) + + progress_cb("decode", 0, 1) + image = decode_latents_to_image(decoder_vae, latents, device) + progress_cb("decode", 1, 1) + del latents, decoder_vae + clear_torch_cache(device) gen_path = os.path.join(tempdir, f"base_{width}x{height}.png") image.save(gen_path)