fix(image_processor): maintain 3-tuple return contract in InpaintProcessor.preprocess when mask is None - #14481
Open
patrickswedish wants to merge 1 commit into
Conversation
|
I closed my duplicate #14807 in favor of this PR after comparing the diffs. This change covers the same no-mask contract and also tests masked and padding-crop paths with the precise optional-mask return type. Could a maintainer review or identify any remaining concern? |
yiyixuxu
reviewed
Oct 2, 2026
| assert postprocessing_kwargs["original_image"] is None | ||
| assert postprocessing_kwargs["original_mask"] is None | ||
|
|
||
| def test_inpaint_processor_preprocess_with_padding_mask_crop(self): |
Collaborator
There was a problem hiding this comment.
can we just reduce to one test? you can use @pytest.mark.parametrize
Author
There was a problem hiding this comment.
Thanks for the feedback, @yiyixuxu! Updated to consolidate into a single @pytest.mark.parametrize test covering the with-mask, without-mask, and crop configurations. Rebased cleanly on latest main, squashed to a single atomic commit, and verified all tests and linting pass locally.
…one (huggingface#14470) Ensure InpaintProcessor.preprocess returns (image, None, postprocessing_kwargs) when mask is None, preserving the expected 3-tuple return contract and signature consistency across all preprocess branches. Consolidate unit tests into a parameterized test covering with-mask, without-mask, and crop configurations.
patrickswedish
force-pushed
the
fix-inpaint-processor-preprocess-contract
branch
from
October 3, 2026 13:16
8816fd2 to
b9bb68a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #14470.
InpaintProcessor.preprocessreturns a 3-tuple(image, mask, postprocessing_kwargs)across all masked execution paths, but whenmask is None, the early return returned only the processed image tensor directly. Callers unpacking the standard 3-value contract (image, mask, postprocessing_kwargs = processor.preprocess(...)) would raiseValueError: not enough values to unpack (expected 3, got 1).Root Cause
When the 3-value contract and
postprocessing_kwargswere introduced in commitf50b18eec(#12220), the early return formask is Nonewas not updated to return the consistent 3-tuple structure. Additionally, the return type annotation indicatedtuple[torch.Tensor, torch.Tensor], which did not reflect the 3-element return value or optional mask.Changes
InpaintProcessor.preprocessinsrc/diffusers/image_processor.pywhenmask is Noneto return(processed_image, None, postprocessing_kwargs)wherepostprocessing_kwargsis populated with{"crops_coords": None, "original_image": None, "original_mask": None}.tuple[torch.Tensor, torch.Tensor | None, dict[str, Any]].tests/others/test_image_processor.pycoveringpreprocesswith mask, without mask (mask=None), and withpadding_mask_crop.Before submitting
Who can review?
@DN6 @yiyixuxu