[qwenimage] add image_area kwarg to QwenImageEditPlusPipeline#13660
Open
david-PHR wants to merge 1 commit intohuggingface:mainfrom
Open
[qwenimage] add image_area kwarg to QwenImageEditPlusPipeline#13660david-PHR wants to merge 1 commit intohuggingface:mainfrom
david-PHR wants to merge 1 commit intohuggingface:mainfrom
Conversation
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?
Adds an
image_areakeyword argument toQwenImageEditPlusPipeline.__call__, letting callers control the target pixel area used for generation. Previously this was hardcoded to1024 * 1024in two places, with no way to override it short of computing and passing bothheightandwidthmanually — and even then the input images were still re-encoded by the VAE at ~1MP regardless.With this PR a user can now do:
image_areacontrols two things consistently:height/widthderived from the input image's aspect ratio when those are not explicitly passed.When
heightandwidthare both passed explicitly they continue to override (1);image_areastill drives (2).Motivation
The pipeline previously offered no way to dial generation/encoding resolution up or down from the ~1MP default. That's restrictive for users who want to trade fidelity for speed (lower) or push for higher fidelity (higher). This PR exposes the existing internal sizing knob as a public kwarg, with no behavior change at the default.
Changes
All changes are confined to
src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit_plus.py:image_area: int = 1024 * 1024kwarg on__call__, placed betweenwidthandnum_inference_stepsto keep resolution-related kwargs grouped.calculate_dimensions(1024 * 1024, ...)→calculate_dimensions(image_area, ...)at the default-dimension call site.calculate_dimensions(VAE_IMAGE_SIZE, ...)→calculate_dimensions(image_area, ...)at the VAE-encode call site.VAE_IMAGE_SIZE = 1024 * 1024. The companion constantCONDITION_IMAGE_SIZE = 384 * 384is kept (it controls VLM token budget for the conditioning branch — a different concern, out of scope here).Backward compatibility
Fully backward-compatible. The default value is exactly the previously-hardcoded
1024 * 1024, so existing call sites get identical behavior.Fixes # N/A — small standalone enhancement, no associated issue.
Before submitting
Local checks:
make fix-copiesclean,ruff format/ruff checkclean.Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.