Fixing bug where width and height are inverted for control image resizing (#707)

This commit is contained in:
abionda-sc
2026-03-28 19:00:32 +00:00
committed by GitHub
parent 700c4b53d0
commit 4ef5cbe5bc
3 changed files with 8 additions and 8 deletions

View File

@@ -377,8 +377,8 @@ class Flux2Model(BaseModel):
"match_target_res", False
):
ratio = control_img.shape[2] / control_img.shape[3]
c_width = math.sqrt(control_image_res * ratio)
c_height = c_width / ratio
c_height = math.sqrt(control_image_res * ratio)
c_width = c_height / ratio
c_width = round(c_width / 32) * 32
c_height = round(c_height / 32) * 32

View File

@@ -181,8 +181,8 @@ class QwenImageEditModel(QwenImageModel):
# images are always run through at 1MP, based on diffusers inference code.
target_area = 1024 * 1024
ratio = control_images.shape[2] / control_images.shape[3]
width = math.sqrt(target_area * ratio)
height = width / ratio
height = math.sqrt(target_area * ratio)
width = height / ratio
width = round(width / 32) * 32
height = round(height / 32) * 32

View File

@@ -176,8 +176,8 @@ class QwenImageEditPlusModel(QwenImageModel):
for i in range(len(control_images)):
# control images are 0 - 1 scale, shape (bs, ch, height, width)
ratio = control_images[i].shape[2] / control_images[i].shape[3]
width = math.sqrt(CONDITION_IMAGE_SIZE * ratio)
height = width / ratio
height = math.sqrt(CONDITION_IMAGE_SIZE * ratio)
width = height / ratio
width = round(width / 32) * 32
height = round(height / 32) * 32
@@ -264,8 +264,8 @@ class QwenImageEditPlusModel(QwenImageModel):
if len(control_img.shape) == 3:
control_img = control_img.unsqueeze(0)
ratio = control_img.shape[2] / control_img.shape[3]
c_width = math.sqrt(control_image_res * ratio)
c_height = c_width / ratio
c_height = math.sqrt(control_image_res * ratio)
c_width = c_height / ratio
c_width = round(c_width / 32) * 32
c_height = round(c_height / 32) * 32