Skip to content

Commit 8a9644c

Browse files
[Bugfix] Fix image edit RoPE crash when explicit height/width are provided (#1265)
Signed-off-by: lishunyang <lishunyang12@163.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
1 parent 8228b5a commit 8a9644c

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

examples/online_serving/image_to_image/openai_chat_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ def edit_image(
7676

7777
# Build extra_body with generation parameters
7878
extra_body = {}
79+
if height is not None:
80+
extra_body["height"] = height
81+
if width is not None:
82+
extra_body["width"] = width
7983
if steps is not None:
8084
extra_body["num_inference_steps"] = steps
8185
if guidance_scale is not None:

examples/online_serving/image_to_image/run_curl_image_edit.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,25 @@ if [[ ! -f "$INPUT_IMG" ]]; then
1919
exit 1
2020
fi
2121

22-
IMG_B64=$(base64 -w0 "$INPUT_IMG")
22+
REQUEST_JSON_FILE=$(mktemp)
23+
trap 'rm -f "$REQUEST_JSON_FILE"' EXIT
2324

24-
REQUEST_JSON=$(
25-
jq -n --arg prompt "$PROMPT" --arg img "$IMG_B64" '{
25+
# Pipe base64 into jq via stdin to avoid ARG_MAX limit on large images
26+
base64 -w0 "$INPUT_IMG" \
27+
| jq -Rs --arg prompt "$PROMPT" '{
2628
messages: [{
2729
role: "user",
2830
content: [
2931
{"type": "text", "text": $prompt},
30-
{"type": "image_url", "image_url": {"url": ("data:image/png;base64," + $img)}}
32+
{"type": "image_url", "image_url": {"url": ("data:image/png;base64," + .)}}
3133
]
3234
}],
3335
extra_body: {
34-
height: 1024,
35-
width: 1024,
3636
num_inference_steps: 50,
3737
guidance_scale: 1,
3838
seed: 42
3939
}
40-
}'
41-
)
40+
}' > "$REQUEST_JSON_FILE"
4241

4342
echo "Generating edited image..."
4443
echo "Server: $SERVER"
@@ -48,7 +47,7 @@ echo "Output: $OUTPUT"
4847

4948
curl -s "$SERVER/v1/chat/completions" \
5049
-H "Content-Type: application/json" \
51-
-d "$REQUEST_JSON" \
50+
-d @"$REQUEST_JSON_FILE" \
5251
| jq -r '.choices[0].message.content[0].image_url.url' \
5352
| cut -d',' -f2 \
5453
| base64 -d > "$OUTPUT"

vllm_omni/diffusion/models/qwen_image/pipeline_qwen_image_edit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ def pre_process_func(
110110
if image is not None and not (
111111
isinstance(image, torch.Tensor) and len(image.shape) > 1 and image.shape[1] == latent_channels
112112
):
113-
image = image_processor.resize(image, height, width)
113+
image = image_processor.resize(image, calculated_height, calculated_width)
114114
prompt_image = image
115-
image = image_processor.preprocess(image, height, width)
115+
image = image_processor.preprocess(image, calculated_height, calculated_width)
116116
image = image.unsqueeze(2)
117117

118118
# Store preprocessed image and prompt image in request

0 commit comments

Comments
 (0)