cd /news/generative-ai/qwen-image-2-1-sd-cpp-terminal-scrip… · home › topics › generative-ai › article
[ARTICLE · art-170085] src=gist.github.com ↗ pub= topic=generative-ai verified=true sentiment=↑ positive

Qwen Image 2.1 - SD.CPP - terminal scripts

A developer published a set of bash scripts for running Qwen Image 2.1 image editing locally through sd.cpp's sd-cli, pairing the Q4_K_M GGUF diffusion model and its bf16 VAE with a Qwen3-VL-8B-Instruct LLM and vision projector. The scripts cover text-guided edits, multi-region instruction-based edits, and LoRA-driven outpainting at 512x512 and 512x768 with 20 steps and a 6.0 CFG scale, logging elapsed time and opening each result automatically.

by read7 min views2 publishedNov 13, 2026

| | #!/bin/bash | | | start_time=$(date +%s) | | | echo "" | | | CURRENT_SEED=$RANDOM | | | OUTPUT_FILE=output/i2i_image-edit_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | | | positive_prompt=""" | | | the sloth fur color is now blue | | | """ | | | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \ | | | --vae models/qwen_image_2.1_vae_bf16.safetensors \ |

|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \ | 
|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \ | 
|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 512 -H 512 --diffusion-fa \ | 
|  | --prompt "{$positive_prompt}" \ | 
|  | --negative-prompt "" \ | 
|  | -r output/t2i_2026-10-03_14_04_17_11803.png \ | 
|  | --output "$OUTPUT_FILE" | 

| | # open the output image in the default associated app. | | | xdg-open "$OUTPUT_FILE" |

|  | end_time=$(date +%s) | 
|  | elapsed=$((end_time - start_time)) | 

| | echo "" | | | echo "Elapsed time: $elapsed seconds" | | | # Wait for the user to press Enter | | | echo "" |

|  | echo "+-----------------------------------------------+" | 
|  | echo "Press [ENTER] to Exit." | 

| | read -r |

| | #!/bin/bash | | | start_time=$(date +%s) | | | echo "" | | | CURRENT_SEED=$RANDOM | | | OUTPUT_FILE=output/i2i_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | | | positive_prompt=""" | | | Remove the metal watch in the blue circle, change the hair in the red circle to black, and replace the area in the green circle with gray short-sleeved linen pajamas. | | | """ | | | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \ | | | --vae models/qwen_image_2.1_vae_bf16.safetensors \ |

|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \ | 
|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \ | 
|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 512 -H 512 --diffusion-fa \ | 
|  | --prompt "{$positive_prompt}" \ | 
|  | --negative-prompt "" \ | 
|  | -r output/example-18.png \ | 
|  | --output "$OUTPUT_FILE" | 

| | # open the output image in the default associated app. | | | xdg-open "$OUTPUT_FILE" |

|  | end_time=$(date +%s) | 
|  | elapsed=$((end_time - start_time)) | 

| | echo "" | | | echo "Elapsed time: $elapsed seconds" | | | # Wait for the user to press Enter | | | echo "" |

|  | echo "+-----------------------------------------------+" | 
|  | echo "Press [ENTER] to Exit." | 

| | read -r |

| | #!/bin/bash | | | start_time=$(date +%s) | | | echo "" | | | CURRENT_SEED=$RANDOM | | | OUTPUT_FILE=output/i2i_outpaint_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | | | positive_prompt=""" | | | lora:qwen-image-2.1-outpaint-v2:1.0 | | | Outpaint the image: replace the solid gray areas with a seamless continuation of the scene, keeping the existing picture unchanged. | | | Scene: <description> | | | """ | | | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \ | | | --vae models/qwen_image_2.1_vae_bf16.safetensors \ |

|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \ | 
|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \ | 
|  | --lora-model-dir ./models/lora/ \ | 
|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 512 -H 768 --diffusion-fa \ | 
|  | --prompt "{$positive_prompt}" \ | 
|  | --negative-prompt "" \ | 
|  | -r output/bladerunner_ana-de-armas_joi_hologram-bridge_01.jpg \ | 
|  | --output "$OUTPUT_FILE" | 

| | # open the output image in the default associated app. | | | xdg-open "$OUTPUT_FILE" |

|  | end_time=$(date +%s) | 
|  | elapsed=$((end_time - start_time)) | 

| | echo "" | | | echo "Elapsed time: $elapsed seconds" | | | # Wait for the user to press Enter | | | echo "" |

|  | echo "+-----------------------------------------------+" | 
|  | echo "Press [ENTER] to Exit." | 

| | read -r |

| | #!/bin/bash | | | start_time=$(date +%s) | | | echo "" | | | CURRENT_SEED=$RANDOM | | | base_image=output/example-18.png | | | style_image=output/i2i_2026-10-04_20_15_08_28547.png | | | OUTPUT_FILE=output/i2i_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | | | positive_prompt=""" | | | apply <image2> art style to <image1> | | | """ | | | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \ | | | --vae models/qwen_image_2.1_vae_bf16.safetensors \ |

|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \ | 
|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \ | 
|  | --cfg-scale 6.0 --steps 20 --sampling-method euler --diffusion-fa \ | 
|  | --prompt "{$positive_prompt}" \ | 
|  | --negative-prompt "" \ | 

| | -r $base_image \ | | | -r $style_image \ | | | --output "$OUTPUT_FILE" | | | # open the output image in the default associated app. | | | xdg-open "$OUTPUT_FILE" |

|  | end_time=$(date +%s) | 
|  | elapsed=$((end_time - start_time)) | 

| | echo "" | | | echo "Elapsed time: $elapsed seconds" | | | # Wait for the user to press Enter | | | echo "" |

|  | echo "+-----------------------------------------------+" | 
|  | echo "Press [ENTER] to Exit." | 

| | read -r |

| | #!/bin/bash | | | start_time=$(date +%s) | | | echo "" | | | CURRENT_SEED=$RANDOM | | | OUTPUT_FILE=output/i2i_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | | | positive_prompt=""" | | | This is an RGBA image with transparency. make the white background transparent. The image has alpha channel and the background is transparent. | | | """ | | | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \ | | | --vae models/qwen_image_2.1_vae_bf16.safetensors \ |

|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \ | 
|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \ | 
|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 512 -H 512 --diffusion-fa \ | 
|  | --prompt "{$positive_prompt}" \ | 
|  | --negative-prompt "" \ | 
|  | -r output/i2i_2026-10-04_20_15_08_28547.png \ | 
|  | --output "$OUTPUT_FILE" | 

| | # open the output image in the default associated app. | | | xdg-open "$OUTPUT_FILE" |

|  | end_time=$(date +%s) | 
|  | elapsed=$((end_time - start_time)) | 

| | echo "" | | | echo "Elapsed time: $elapsed seconds" | | | # Wait for the user to press Enter | | | echo "" |

|  | echo "+-----------------------------------------------+" | 
|  | echo "Press [ENTER] to Exit." | 

| | read -r |

| | #!/bin/bash | | | start_time=$(date +%s) | | | echo "" | | | CURRENT_SEED=$RANDOM | | | OUTPUT_FILE=output/i2i_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | | | input_prompt=""" | | | a cartoon sloth mascot waving, flat vector illustration, bright colours | | | """ | | | # do not change positive_prompt as the model was trained to accept this schema. | | | positive_prompt=""" | | | This is an RGBA image with transparency. {$input_prompt}. The image has alpha channel and the background is transparent. | | | """ | | | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \ | | | --vae models/qwen_image_2.1_vae_bf16.safetensors \ |

|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \ | 
|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \ | 
|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 512 -H 512 --diffusion-fa \ | 
|  | --prompt "{$positive_prompt}" \ | 
|  | --negative-prompt "" \ | 
|  | --output "$OUTPUT_FILE" | 

| | # open the output image in the default associated app. | | | xdg-open "$OUTPUT_FILE" |

|  | end_time=$(date +%s) | 
|  | elapsed=$((end_time - start_time)) | 

| | echo "" | | | echo "Elapsed time: $elapsed seconds" | | | # Wait for the user to press Enter | | | echo "" |

|  | echo "+-----------------------------------------------+" | 
|  | echo "Press [ENTER] to Exit." | 

| | read -r |

| | #!/bin/bash | | | start_time=$(date +%s) | | | echo "" | | | CURRENT_SEED=$RANDOM | | | OUTPUT_FILE=output/i2i_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | | | positive_prompt=""" | | | a cartoon sloth mascot waving, flat vector illustration, bright colours. | | | """ | | | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \ | | | --vae models/qwen_image_2.1_vae_bf16.safetensors \ |

|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \ | 
|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \ | 
|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 1024 -H 1024 --diffusion-fa \ | 
|  | --prompt "{$positive_prompt}" \ | 
|  | --negative-prompt "" \ | 
|  | --output "$OUTPUT_FILE" | 

| | # open the output image in the default associated app. | | | xdg-open "$OUTPUT_FILE" |

|  | end_time=$(date +%s) | 
|  | elapsed=$((end_time - start_time)) | 

| | echo "" | | | echo "Elapsed time: $elapsed seconds" | | | # Wait for the user to press Enter | | | echo "" |

|  | echo "+-----------------------------------------------+" | 
|  | echo "Press [ENTER] to Exit." | 

| | read -r |

── more in #generative-ai 4 stories · sorted by recency
── more on @qwen 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/qwen-image-2-1-sd-cp…] indexed:0 read:7min 2026-11-13 · —