{"slug": "qwen-image-2-1-sd-cpp-terminal-scripts", "title": "Qwen Image 2.1 - SD.CPP - terminal scripts", "summary": "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.", "body_md": "|  | #!/bin/bash | \n|  | start_time=$(date +%s) | \n|  | echo \"\" | \n|  | CURRENT_SEED=$RANDOM | \n|  | OUTPUT_FILE=output/i2i_image-edit_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | \n|  | positive_prompt=\"\"\" | \n|  | the sloth fur color is now blue | \n|  | \"\"\" | \n|  | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \\ | \n|  | --vae models/qwen_image_2.1_vae_bf16.safetensors \\ | \n|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \\ | \n|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \\ | \n|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 512 -H 512 --diffusion-fa \\ | \n|  | --prompt \"{$positive_prompt}\" \\ | \n|  | --negative-prompt \"\" \\ | \n|  | -r output/t2i_2026-10-03_14_04_17_11803.png \\ | \n|  | --output \"$OUTPUT_FILE\" | \n|  | # open the output image in the default associated app. | \n|  | xdg-open \"$OUTPUT_FILE\" | \n|  | end_time=$(date +%s) | \n|  | elapsed=$((end_time - start_time)) | \n|  | echo \"\" | \n|  | echo \"Elapsed time: $elapsed seconds\" | \n|  | # Wait for the user to press Enter | \n|  | echo \"\" | \n|  | echo \"+-----------------------------------------------+\" | \n|  | echo \"Press [ENTER] to Exit.\" | \n|  | read -r | \n\n|  | #!/bin/bash | \n|  | start_time=$(date +%s) | \n|  | echo \"\" | \n|  | CURRENT_SEED=$RANDOM | \n|  | OUTPUT_FILE=output/i2i_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | \n|  | positive_prompt=\"\"\" | \n|  | 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. | \n|  | \"\"\" | \n|  | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \\ | \n|  | --vae models/qwen_image_2.1_vae_bf16.safetensors \\ | \n|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \\ | \n|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \\ | \n|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 512 -H 512 --diffusion-fa \\ | \n|  | --prompt \"{$positive_prompt}\" \\ | \n|  | --negative-prompt \"\" \\ | \n|  | -r output/example-18.png \\ | \n|  | --output \"$OUTPUT_FILE\" | \n|  | # open the output image in the default associated app. | \n|  | xdg-open \"$OUTPUT_FILE\" | \n|  | end_time=$(date +%s) | \n|  | elapsed=$((end_time - start_time)) | \n|  | echo \"\" | \n|  | echo \"Elapsed time: $elapsed seconds\" | \n|  | # Wait for the user to press Enter | \n|  | echo \"\" | \n|  | echo \"+-----------------------------------------------+\" | \n|  | echo \"Press [ENTER] to Exit.\" | \n|  | read -r | \n\n|  | #!/bin/bash | \n|  | start_time=$(date +%s) | \n|  | echo \"\" | \n|  | CURRENT_SEED=$RANDOM | \n|  | OUTPUT_FILE=output/i2i_outpaint_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | \n|  | positive_prompt=\"\"\" | \n|  | <lora:qwen-image-2.1-outpaint-v2:1.0> | \n|  | Outpaint the image: replace the solid gray areas with a seamless continuation of the scene, keeping the existing picture unchanged. | \n|  | Scene: <description> | \n|  | \"\"\" | \n|  | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \\ | \n|  | --vae models/qwen_image_2.1_vae_bf16.safetensors \\ | \n|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \\ | \n|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \\ | \n|  | --lora-model-dir ./models/lora/ \\ | \n|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 512 -H 768 --diffusion-fa \\ | \n|  | --prompt \"{$positive_prompt}\" \\ | \n|  | --negative-prompt \"\" \\ | \n|  | -r output/bladerunner_ana-de-armas_joi_hologram-bridge_01.jpg \\ | \n|  | --output \"$OUTPUT_FILE\" | \n|  | # open the output image in the default associated app. | \n|  | xdg-open \"$OUTPUT_FILE\" | \n|  | end_time=$(date +%s) | \n|  | elapsed=$((end_time - start_time)) | \n|  | echo \"\" | \n|  | echo \"Elapsed time: $elapsed seconds\" | \n|  | # Wait for the user to press Enter | \n|  | echo \"\" | \n|  | echo \"+-----------------------------------------------+\" | \n|  | echo \"Press [ENTER] to Exit.\" | \n|  | read -r | \n\n|  | #!/bin/bash | \n|  | start_time=$(date +%s) | \n|  | echo \"\" | \n|  | CURRENT_SEED=$RANDOM | \n|  | base_image=output/example-18.png | \n|  | style_image=output/i2i_2026-10-04_20_15_08_28547.png | \n|  | OUTPUT_FILE=output/i2i_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | \n|  | positive_prompt=\"\"\" | \n|  | apply <image2> art style to <image1> | \n|  | \"\"\" | \n|  | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \\ | \n|  | --vae models/qwen_image_2.1_vae_bf16.safetensors \\ | \n|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \\ | \n|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \\ | \n|  | --cfg-scale 6.0 --steps 20 --sampling-method euler --diffusion-fa \\ | \n|  | --prompt \"{$positive_prompt}\" \\ | \n|  | --negative-prompt \"\" \\ | \n|  | -r $base_image \\ | \n|  | -r $style_image \\ | \n|  | --output \"$OUTPUT_FILE\" | \n|  | # open the output image in the default associated app. | \n|  | xdg-open \"$OUTPUT_FILE\" | \n|  | end_time=$(date +%s) | \n|  | elapsed=$((end_time - start_time)) | \n|  | echo \"\" | \n|  | echo \"Elapsed time: $elapsed seconds\" | \n|  | # Wait for the user to press Enter | \n|  | echo \"\" | \n|  | echo \"+-----------------------------------------------+\" | \n|  | echo \"Press [ENTER] to Exit.\" | \n|  | read -r | \n\n|  | #!/bin/bash | \n|  | start_time=$(date +%s) | \n|  | echo \"\" | \n|  | CURRENT_SEED=$RANDOM | \n|  | OUTPUT_FILE=output/i2i_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | \n|  | positive_prompt=\"\"\" | \n|  | This is an RGBA image with transparency. make the white background transparent. The image has alpha channel and the background is transparent. | \n|  | \"\"\" | \n|  | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \\ | \n|  | --vae models/qwen_image_2.1_vae_bf16.safetensors \\ | \n|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \\ | \n|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \\ | \n|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 512 -H 512 --diffusion-fa \\ | \n|  | --prompt \"{$positive_prompt}\" \\ | \n|  | --negative-prompt \"\" \\ | \n|  | -r output/i2i_2026-10-04_20_15_08_28547.png \\ | \n|  | --output \"$OUTPUT_FILE\" | \n|  | # open the output image in the default associated app. | \n|  | xdg-open \"$OUTPUT_FILE\" | \n|  | end_time=$(date +%s) | \n|  | elapsed=$((end_time - start_time)) | \n|  | echo \"\" | \n|  | echo \"Elapsed time: $elapsed seconds\" | \n|  | # Wait for the user to press Enter | \n|  | echo \"\" | \n|  | echo \"+-----------------------------------------------+\" | \n|  | echo \"Press [ENTER] to Exit.\" | \n|  | read -r | \n\n|  | #!/bin/bash | \n|  | start_time=$(date +%s) | \n|  | echo \"\" | \n|  | CURRENT_SEED=$RANDOM | \n|  | OUTPUT_FILE=output/i2i_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | \n|  | input_prompt=\"\"\" | \n|  | a cartoon sloth mascot waving, flat vector illustration, bright colours | \n|  | \"\"\" | \n|  | # do not change `positive_prompt` as the model was trained to accept this schema. | \n|  | positive_prompt=\"\"\" | \n|  | This is an RGBA image with transparency. {$input_prompt}. The image has alpha channel and the background is transparent. | \n|  | \"\"\" | \n|  | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \\ | \n|  | --vae models/qwen_image_2.1_vae_bf16.safetensors \\ | \n|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \\ | \n|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \\ | \n|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 512 -H 512 --diffusion-fa \\ | \n|  | --prompt \"{$positive_prompt}\" \\ | \n|  | --negative-prompt \"\" \\ | \n|  | --output \"$OUTPUT_FILE\" | \n|  | # open the output image in the default associated app. | \n|  | xdg-open \"$OUTPUT_FILE\" | \n|  | end_time=$(date +%s) | \n|  | elapsed=$((end_time - start_time)) | \n|  | echo \"\" | \n|  | echo \"Elapsed time: $elapsed seconds\" | \n|  | # Wait for the user to press Enter | \n|  | echo \"\" | \n|  | echo \"+-----------------------------------------------+\" | \n|  | echo \"Press [ENTER] to Exit.\" | \n|  | read -r | \n\n|  | #!/bin/bash | \n|  | start_time=$(date +%s) | \n|  | echo \"\" | \n|  | CURRENT_SEED=$RANDOM | \n|  | OUTPUT_FILE=output/i2i_$( date '+%F_%H_%M_%S' )_$CURRENT_SEED.png | \n|  | positive_prompt=\"\"\" | \n|  | a cartoon sloth mascot waving, flat vector illustration, bright colours. | \n|  | \"\"\" | \n|  | ./sd-cpp/sd-cli --diffusion-model models/qwen-image-2.1-Q4_K_M.gguf \\ | \n|  | --vae models/qwen_image_2.1_vae_bf16.safetensors \\ | \n|  | --llm models/Qwen3-VL-8B-Instruct-Q4_0.gguf \\ | \n|  | --llm_vision models/mmproj-F16_Qwen3-VL-8B-Instruct.gguf \\ | \n|  | --cfg-scale 6.0 --steps 20 --sampling-method euler -W 1024 -H 1024 --diffusion-fa \\ | \n|  | --prompt \"{$positive_prompt}\" \\ | \n|  | --negative-prompt \"\" \\ | \n|  | --output \"$OUTPUT_FILE\" | \n|  | # open the output image in the default associated app. | \n|  | xdg-open \"$OUTPUT_FILE\" | \n|  | end_time=$(date +%s) | \n|  | elapsed=$((end_time - start_time)) | \n|  | echo \"\" | \n|  | echo \"Elapsed time: $elapsed seconds\" | \n|  | # Wait for the user to press Enter | \n|  | echo \"\" | \n|  | echo \"+-----------------------------------------------+\" | \n|  | echo \"Press [ENTER] to Exit.\" | \n|  | read -r |", "url": "https://wpnews.pro/news/qwen-image-2-1-sd-cpp-terminal-scripts", "canonical_source": "https://gist.github.com/ricardosantos79/e37510c6a0f029d402b403c1aa814393", "published_at": "2026-11-13 09:34:07+00:00", "updated_at": "2026-11-15 18:51:07.966798+00:00", "lang": "en", "topics": ["generative-ai", "ai-tools", "computer-vision", "large-language-models", "developer-tools"], "entities": ["Qwen", "Qwen Image 2.1", "sd.cpp", "Qwen3-VL-8B-Instruct"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/qwen-image-2-1-sd-cpp-terminal-scripts", "markdown": "https://wpnews.pro/news/qwen-image-2-1-sd-cpp-terminal-scripts.md", "text": "https://wpnews.pro/news/qwen-image-2-1-sd-cpp-terminal-scripts.txt", "jsonld": "https://wpnews.pro/news/qwen-image-2-1-sd-cpp-terminal-scripts.jsonld"}}