Repository navigation
Conversation
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.
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?
InpaintProcessor.preprocess()raisedTypeErrorwhenpadding_mask_cropwas set andheightand/orwidthwere omitted.get_crop_regiondivideswidthbyheightbefore those dimensions are inferred.Omitted dimensions are now resolved with
VaeImageProcessor.get_default_height_widthbefore the crop, and the image and mask are resized to that processing size. Explicitheightandwidthare unchanged. A regression test covers the reported case (both dimensions omitted, either dimension omitted, a size that is not a multiple ofvae_scale_factor, and explicit dimensions).Fixes #15433
Self-review notes
Verdict: READY
I reviewed the full diff (
src/diffusers/image_processor.pyandtests/others/test_image_processor.py).The crash was in
get_crop_region, which divideswidthbyheight. The fix callsget_default_height_widthfirst, which is the same inferenceVaeImageProcessor.preprocessalready uses when resizing. For a list of images, the size is taken fromimage[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
self-reviewskill on the diff?documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed.