moose Claude Opus 4.7 (1M context) commited on
Commit ·
efe093f
1
Parent(s): b34fbef
Preserve input image aspect ratio when sliders are at default
Browse filesThe Qwen-Image-Edit pipeline defaults to 1024x1024 when given height=None
and width=None, which discards the input image's aspect ratio. When the
user hasn't touched the height/width sliders (both still at the slider
minimum of 256), read the dimensions from input image 1 and pass those
to the pipeline instead, snapped to the nearest multiple of 8 and
clamped to the slider's [256, 2048] range.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
216 unmodified lines217218219220221222223224216 unmodified linesexcept Exception:continueif height==256 and width==256:height, width = None, Noneprint(f"Calling pipeline with prompt: '{prompt}'")print(f"Negative Prompt: '{negative_prompt}'")print(f"Seed: {seed}, Steps: {num_inference_steps}, Guidance: {true_guidance_scale}, Size: {width}x{height}")216 unmodified lines217218219220221222223224225226227228229230231232233216 unmodified linesexcept Exception:continue# If user left the sliders at their default minimum, derive output dimensions# from input image 1 so the result preserves its aspect ratio. Round to the# nearest multiple of 8 (the pipeline's required dimension step) and clamp# to the slider's [256, 2048] range.if height == 256 and width == 256:if pil_images:ref_w, ref_h = pil_images[0].sizewidth = max(256, min(2048, (ref_w // 8) * 8))height = max(256, min(2048, (ref_h // 8) * 8))else:height, width = None, Noneprint(f"Calling pipeline with prompt: '{prompt}'")print(f"Negative Prompt: '{negative_prompt}'")print(f"Seed: {seed}, Steps: {num_inference_steps}, Guidance: {true_guidance_scale}, Size: {width}x{height}")
app.py+11-2