File tree Expand file tree Collapse file tree
examples/online_serving/image_to_image
vllm_omni/diffusion/models/qwen_image Expand file tree Collapse file tree Original file line number Diff line number Diff 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 :
Original file line number Diff line number Diff line change @@ -19,26 +19,25 @@ if [[ ! -f "$INPUT_IMG" ]]; then
1919 exit 1
2020fi
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
4342echo " Generating edited image..."
4443echo " Server: $SERVER "
@@ -48,7 +47,7 @@ echo "Output: $OUTPUT"
4847
4948curl -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 "
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments