Skip to content

Fix VaeImageProcessorLDM3D silently discarding its own constructor arguments - #14662

Open
afonsojanu wants to merge 1 commit into
huggingface:mainfrom
afonsojanu:fix/ldm3d-image-processor-config-clobber
Open

Fix VaeImageProcessorLDM3D silently discarding its own constructor arguments#14662
afonsojanu wants to merge 1 commit into
huggingface:mainfrom
afonsojanu:fix/ldm3d-image-processor-config-clobber

Conversation

@afonsojanu

Copy link
Copy Markdown

Fixes #14429

VaeImageProcessorLDM3D's constructor accepts do_resize, vae_scale_factor, resample, and do_normalize, but the body just calls super().init() with nothing. VaeImageProcessor's own init is decorated with @register_to_config too, so that empty call re-runs its wrapper with the base class's own defaults for those exact four names, and register_to_config merges new values over the existing dict rather than skipping keys already set. The net effect: whatever LDM3D registered a line earlier gets clobbered right back to VaeImageProcessor's defaults before the constructor even returns.

p = VaeImageProcessorLDM3D(do_resize=False, vae_scale_factor=16, resample="bilinear", do_normalize=False)
p.config.do_resize          # True, not False
p.config.vae_scale_factor   # 8, not 16

Two other VaeImageProcessor subclasses in this same file, IPAdapterMaskProcessor and PixArtImageProcessor, already forward their arguments explicitly to super().init(...), so this brings LDM3D in line with that.

Added a test alongside the rest of tests/others/test_image_processor.py that constructs the processor with all four non-default values and checks they survive, plus a defaults case for the other direction. Reverted just the source change locally to confirm the new test fails with the exact clobbering behavior described above, then restored it. Ran the full image processor and config test suites, 22 passed. ruff check and ruff format both clean on the touched files.

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.
@github-actions github-actions Bot added tests fixes-issue size/S PR with diff < 50 LOC labels Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixes-issue size/S PR with diff < 50 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VaeImageProcessorLDM3D ignores constructor configuration arguments

1 participant