From 8a9644c8213b6a7234f6cf781d19ef417e301e1a Mon Sep 17 00:00:00 2001 From: SYLAR <125541396+lishunyang12@users.noreply.github.com> Date: Wed, 11 Feb 2026 05:18:36 +0800 Subject: [PATCH] [Bugfix] Fix image edit RoPE crash when explicit height/width are provided (#1265) Signed-off-by: lishunyang Co-authored-by: Hongsheng Liu --- .../image_to_image/openai_chat_client.py | 4 ++++ .../image_to_image/run_curl_image_edit.sh | 17 ++++++++--------- .../qwen_image/pipeline_qwen_image_edit.py | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/online_serving/image_to_image/openai_chat_client.py b/examples/online_serving/image_to_image/openai_chat_client.py index 0fe4b0ede..7aac2b214 100644 --- a/examples/online_serving/image_to_image/openai_chat_client.py +++ b/examples/online_serving/image_to_image/openai_chat_client.py @@ -76,6 +76,10 @@ def edit_image( # Build extra_body with generation parameters extra_body = {} + if height is not None: + extra_body["height"] = height + if width is not None: + extra_body["width"] = width if steps is not None: extra_body["num_inference_steps"] = steps if guidance_scale is not None: diff --git a/examples/online_serving/image_to_image/run_curl_image_edit.sh b/examples/online_serving/image_to_image/run_curl_image_edit.sh index 748a0ebe5..1a5328685 100644 --- a/examples/online_serving/image_to_image/run_curl_image_edit.sh +++ b/examples/online_serving/image_to_image/run_curl_image_edit.sh @@ -19,26 +19,25 @@ if [[ ! -f "$INPUT_IMG" ]]; then exit 1 fi -IMG_B64=$(base64 -w0 "$INPUT_IMG") +REQUEST_JSON_FILE=$(mktemp) +trap 'rm -f "$REQUEST_JSON_FILE"' EXIT -REQUEST_JSON=$( - jq -n --arg prompt "$PROMPT" --arg img "$IMG_B64" '{ +# Pipe base64 into jq via stdin to avoid ARG_MAX limit on large images +base64 -w0 "$INPUT_IMG" \ + | jq -Rs --arg prompt "$PROMPT" '{ messages: [{ role: "user", content: [ {"type": "text", "text": $prompt}, - {"type": "image_url", "image_url": {"url": ("data:image/png;base64," + $img)}} + {"type": "image_url", "image_url": {"url": ("data:image/png;base64," + .)}} ] }], extra_body: { - height: 1024, - width: 1024, num_inference_steps: 50, guidance_scale: 1, seed: 42 } - }' -) + }' > "$REQUEST_JSON_FILE" echo "Generating edited image..." echo "Server: $SERVER" @@ -48,7 +47,7 @@ echo "Output: $OUTPUT" curl -s "$SERVER/v1/chat/completions" \ -H "Content-Type: application/json" \ - -d "$REQUEST_JSON" \ + -d @"$REQUEST_JSON_FILE" \ | jq -r '.choices[0].message.content[0].image_url.url' \ | cut -d',' -f2 \ | base64 -d > "$OUTPUT" diff --git a/vllm_omni/diffusion/models/qwen_image/pipeline_qwen_image_edit.py b/vllm_omni/diffusion/models/qwen_image/pipeline_qwen_image_edit.py index 082c9e754..bff248a44 100644 --- a/vllm_omni/diffusion/models/qwen_image/pipeline_qwen_image_edit.py +++ b/vllm_omni/diffusion/models/qwen_image/pipeline_qwen_image_edit.py @@ -110,9 +110,9 @@ def get_qwen_image_edit_pre_process_func( if image is not None and not ( isinstance(image, torch.Tensor) and len(image.shape) > 1 and image.shape[1] == latent_channels ): - image = image_processor.resize(image, height, width) + image = image_processor.resize(image, calculated_height, calculated_width) prompt_image = image - image = image_processor.preprocess(image, height, width) + image = image_processor.preprocess(image, calculated_height, calculated_width) image = image.unsqueeze(2) # Store preprocessed image and prompt image in request