From d67348a0a54a4d4c612673d3622ef0a617036646 Mon Sep 17 00:00:00 2001 From: AUTOMATIC1111 <16777216c@gmail.com> Date: Fri, 28 Jun 2024 18:06:49 +0300 Subject: [PATCH] allow generation to be started with any dimensions specified --- modules/models/sd3/sd3_model.py | 3 +++ modules/processing.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/modules/models/sd3/sd3_model.py b/modules/models/sd3/sd3_model.py index 336e8d2d4..2d66b80f1 100644 --- a/modules/models/sd3/sd3_model.py +++ b/modules/models/sd3/sd3_model.py @@ -75,3 +75,6 @@ class SD3Inferencer(torch.nn.Module): def add_noise_to_latent(self, x, noise, amount): return x * (1 - amount) + noise * amount + + def fix_dimensions(self, width, height): + return width // 16 * 16, height // 16 * 16 diff --git a/modules/processing.py b/modules/processing.py index c3ce975ea..7535b56e1 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -884,6 +884,9 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: if p.refiner_checkpoint_info is None: raise Exception(f'Could not find checkpoint with name {p.refiner_checkpoint}') + if hasattr(shared.sd_model, 'fix_dimensions'): + p.width, p.height = shared.sd_model.fix_dimensions(p.width, p.height) + p.sd_model_name = shared.sd_model.sd_checkpoint_info.name_for_extra p.sd_model_hash = shared.sd_model.sd_model_hash p.sd_vae_name = sd_vae.get_loaded_vae_name()