Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/models/qwen_image_edit.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
7 changes: 7 additions & 0 deletions src/conditioning/conditioner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2900,6 +2900,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);
Expand Down
Loading