Skip to content

Fix InpaintProcessor crash when padding_mask_crop omits a dimension - #15443

Open
QTSHI wants to merge 1 commit into
huggingface:mainfrom
QTSHI:cursor/inpaint-padding-mask-crop-dims-5ce4
Open

QTSHI wants to merge 1 commit into
huggingface:mainfrom
QTSHI:cursor/inpaint-padding-mask-crop-dims-5ce4

Conversation

@QTSHI

@QTSHI QTSHI commented Dec 1, 2026

Copy link
Copy Markdown

What does this PR do?

InpaintProcessor.preprocess() raised TypeError when padding_mask_crop was set and height and/or width were omitted. get_crop_region divides width by height before those dimensions are inferred.

Omitted dimensions are now resolved with VaeImageProcessor.get_default_height_width before the crop, and the image and mask are resized to that processing size. Explicit height and width are unchanged. A regression test covers the reported case (both dimensions omitted, either dimension omitted, a size that is not a multiple of vae_scale_factor, and explicit dimensions).

Fixes #15433

Self-review notes

Verdict: READY

I reviewed the full diff (src/diffusers/image_processor.py and tests/others/test_image_processor.py).

  • Fix before submitting: none.
  • Leave for the actual review: none.

The crash was in get_crop_region, which divides width by height. The fix calls get_default_height_width first, which is the same inference VaeImageProcessor.preprocess already uses when resizing. For a list of images, the size is taken from image[0], consistent with how the processor typically treats a batch. Explicit dimensions are left unchanged.

pytest tests/others/test_image_processor.py: 19 passed.

Before submitting

  • Did you use an AI agent (Claude Code, Codex, Cursor, etc.) to help with this PR? If so:
    • Did you read the Coding with AI agents guide?
    • Did you run the self-review skill on the diff?
    • Did you share the final self-review notes in the PR description or a comment?
  • Did you read the contributor guideline?
  • Did you read our philosophy doc? (important for complex PRs)
  • Was this discussed/approved via a GitHub issue or GitHub Discussions? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?
  • Are you the author (or part of the team we work with) of the model/pipeline this PR relates to?

Who can review?

Anyone in the community is free to review the PR once the tests have passed.

get_crop_region divides width by height. Infer omitted dimensions with
get_default_height_width before that division, and resize to the same
processing size preprocess uses without cropping.
@github-actions github-actions Bot added tests fixes-issue size/M PR with diff < 200 LOC labels Dec 1, 2026
@QTSHI QTSHI closed this Dec 3, 2026
@QTSHI
QTSHI deleted the cursor/inpaint-padding-mask-crop-dims-5ce4 branch December 3, 2026 02:43
@QTSHI
QTSHI restored the cursor/inpaint-padding-mask-crop-dims-5ce4 branch December 3, 2026 02:45
@QTSHI QTSHI reopened this Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixes-issue size/M PR with diff < 200 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InpaintProcessor crashes when padding_mask_crop is set and a dimension is omitted

1 participant