From 131195276ae602a9c20cb2c7e8c204d0f0d3121e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Afonso=20Janu=C3=A1rio?= Date: Mon, 31 Aug 2026 12:06:34 +0100 Subject: [PATCH] Forward VaeImageProcessorLDM3D's constructor args to its base class VaeImageProcessorLDM3D.__init__ called super().__init__() with no arguments, even though it accepts do_resize, vae_scale_factor, resample, and do_normalize. Since VaeImageProcessor's own __init__ is also wrapped by @register_to_config, that empty call re-registered the base class's defaults for those same four keys right on top of the values LDM3D had just registered a moment earlier, so anything other than the defaults passed to LDM3D silently got thrown away. Forward the received arguments the same way IPAdapterMaskProcessor and PixArtImageProcessor already do for their own super().__init__() call. --- src/diffusers/image_processor.py | 7 ++++++- tests/others/test_image_processor.py | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/diffusers/image_processor.py b/src/diffusers/image_processor.py index 4f6f4bd52b9c..a691cd19f59a 100644 --- a/src/diffusers/image_processor.py +++ b/src/diffusers/image_processor.py @@ -989,7 +989,12 @@ def __init__( resample: str = "lanczos", do_normalize: bool = True, ): - super().__init__() + super().__init__( + do_resize=do_resize, + vae_scale_factor=vae_scale_factor, + resample=resample, + do_normalize=do_normalize, + ) @staticmethod def numpy_to_pil(images: np.ndarray) -> list[PIL.Image.Image]: diff --git a/tests/others/test_image_processor.py b/tests/others/test_image_processor.py index 0d358699f105..31933dc23445 100644 --- a/tests/others/test_image_processor.py +++ b/tests/others/test_image_processor.py @@ -17,7 +17,7 @@ import PIL.Image import torch -from diffusers.image_processor import VaeImageProcessor +from diffusers.image_processor import VaeImageProcessor, VaeImageProcessorLDM3D class TestImageProcessor: @@ -306,3 +306,21 @@ def test_vae_image_processor_resize_np(self): assert out_np.shape == exp_np_shape, ( f"resized image output shape '{out_np.shape}' didn't match expected shape '{exp_np_shape}'." ) + + def test_vae_image_processor_ldm3d_keeps_its_own_config(self): + # LDM3D's __init__ used to call super().__init__() with no arguments, so the base + # class's own @register_to_config wrapper re-registered its defaults over whatever + # LDM3D had just registered, silently discarding any non-default value passed in. + image_processor = VaeImageProcessorLDM3D( + do_resize=False, vae_scale_factor=16, resample="bilinear", do_normalize=False + ) + assert image_processor.config.do_resize is False + assert image_processor.config.vae_scale_factor == 16 + assert image_processor.config.resample == "bilinear" + assert image_processor.config.do_normalize is False + + default_processor = VaeImageProcessorLDM3D() + assert default_processor.config.do_resize is True + assert default_processor.config.vae_scale_factor == 8 + assert default_processor.config.resample == "lanczos" + assert default_processor.config.do_normalize is True