fix: resize Qwen Image Edit vision references (#2433)

This commit is contained in:
leejet 2026-11-26 21:03:58 +08:00 • committed by GitHub
parent 52491bd9f1
commit 456f52d2de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View file

@ -178,3 +178,9 @@ To use the new Qwen Image Edit 2511 mode, `--model-args qwen_image_zero_cond_t=t
```
<img alt="qwen_image_edit_2509" src="../../assets/qwen/qwen_image_edit_2511.png" />
## 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.

View file

@ -2931,6 +2931,13 @@ struct LLMEmbedder : public Conditioner {
int h_bar = static_cast<int>(std::round(static_cast<double>(height) / factor) * factor);
int w_bar = static_cast<int>(std::round(static_cast<double>(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<double>(width) * height));
h_bar = std::max(factor, static_cast<int>(std::round(height * scale / factor)) * factor);
w_bar = std::max(factor, static_cast<int>(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);