diff --git a/docs/models/qwen_image_edit.md b/docs/models/qwen_image_edit.md index 3dacdaee..fd701f23 100644 --- a/docs/models/qwen_image_edit.md +++ b/docs/models/qwen_image_edit.md @@ -178,3 +178,9 @@ To use the new Qwen Image Edit 2511 mode, `--model-args qwen_image_zero_cond_t=t ``` qwen_image_edit_2509 + +## Notes and limitations + +The vision encoder uses a target area of `384 × 384` pixels for each reference +image, preserving its aspect ratio up to the encoder's patch alignment. VAE +reference latents use a separate resize based on the output size. diff --git a/src/conditioning/conditioner.hpp b/src/conditioning/conditioner.hpp index 331e33b7..cefb9053 100644 --- a/src/conditioning/conditioner.hpp +++ b/src/conditioning/conditioner.hpp @@ -2931,6 +2931,13 @@ struct LLMEmbedder : public Conditioner { int h_bar = static_cast(std::round(static_cast(height) / factor) * factor); int w_bar = static_cast(std::round(static_cast(width) / factor) * factor); + if (version == VERSION_QWEN_IMAGE) { + constexpr double target_area = 384.0 * 384.0; + const double scale = std::sqrt(target_area / (static_cast(width) * height)); + h_bar = std::max(factor, static_cast(std::round(height * scale / factor)) * factor); + w_bar = std::max(factor, static_cast(std::round(width * scale / factor)) * factor); + } + LOG_VERBOSE("resize conditioner ref image %d from %dx%d to %dx%d", i, height, width, h_bar, w_bar); auto resized_image = clip_preprocess(image, w_bar, h_bar);