mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-26 23:29:53 +00:00
fix: resize Qwen Image Edit vision references (#2433)
This commit is contained in:
parent
52491bd9f1
commit
456f52d2de
2 changed files with 13 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue