Image Editing using Qwen-Image via Command Line (AMD GPU/CPU Support)

This article can be read in about 7 minutes.
PR

The purpose

Image Editing using Qwen-Image via Command Line (AMD GPU/CPU Support) Qwen-Image from the command line using stable-diffusion.cpp. It can be executed on both AMD GPUs and CPUs.

PR

Build environment

stable-diffusion.cpp

Download the ZIP file that matches your environment from the following page.

Releases · leejet/stable-diffusion.cpp
Diffusion model(SD,Flux,Wan,Qwen Image,Z-Image,...) inference in pure C/C++ - leejet/stable-diffusion.cpp

If you want to run it on an AMD GPU, look for versions labeled Vulkan or ROCm.

(Generally, Vulkan should be fine. ROCm tends to support a more limited range of GPUs.)

For NVIDIA GPUs, look for versions labeled “CUDA“.

The AVX512, AVX2, AVX, and No-AVX versions are for CPU operation. Please check which AVX version your CPU supports before downloading. (I was under the impression they weren’t, but it turns out AMD CPUs also support AVX. The easiest way to check your specific version is to ask an AI.)

Once you have extracted the downloaded file to a folder of your choice, the setup is complete.

Model

Please download one model from each of the following pages, for a total of three models.

The VAE and LLM models are the same as those used in the article below. (Please note that the Diffusion model is different.)

Regarding cases where multiple files are available, larger files require more memory but offer higher accuracy. Please decide which model to use based on your system environment.

On my setup (Ryzen 7 7735HS with Radeon Graphics + 32GB RAM), the Q8_0.gguf version didn’t work, so I used Q4_K_S.gguf instead.

diffusion-model

QuantStack/Qwen-Image-Edit-GGUF at main
We’re on a journey to advance and democratize artificial intelligence through open source and open science.

vae

Comfy-Org/Qwen-Image_ComfyUI at main
We’re on a journey to advance and democratize artificial intelligence through open source and open science.

llm

mradermacher/Qwen2.5-VL-7B-Instruct-GGUF at main
We’re on a journey to advance and democratize artificial intelligence through open source and open science.
PR

Execute

Open the command line and navigate to the folder where you extracted stable-diffusion.cpp.

Run the following command. (Replace “model path” with the actual path of the model you are using. Replace “input_image_path” with the actual path of the input image you are using.)

sd-cli.exe --diffusion-model Diffusion_model_path --vae  VAE_model_path  --llm llm_model_path --cfg-scale 2.5 --sampling-method euler  --offload-to-cpu --diffusion-fa --flow-shift 3 -r input_image_path -p "change eye color to red" --seed -1

It is successful if a cat has red eyes image is generated in ./output.png.

Input

Output

Option (Argument)

The options are summarized on the following page.

stable-diffusion.cpp/examples/cli/README.md at master · leejet/stable-diffusion.cpp
Diffusion model(SD,Flux,Wan,Qwen Image,Z-Image,...) inference in pure C/C++ - leejet/stable-diffusion.cpp

Only the most commonly used ones are listed below.

-mpath for Model
-pprompt
-sSeed
To generate a random image, specify -1. Note that if this is not specified, the same image will be generated every time.
-HImage height
-WImage width
--vaepath for VAE
--stepsStep
default 20
Be careful, as some models perform better with lower values.

Execute time

Image generation speeds are as follows. (This excludes model loading time and post-iteration processing.)

Creation Time(s)
stable-diffusion(Vulkan)36
Qwen Image(Vulkan)623
Qwen Image Edit(Vulkan)1683

Reference

PR

about Qwen Image Edit 2509

The Qwen Image Edit 2509 model can be found on the following page.

I was able to get it working by replacing the Diffusion model path in the Qwen Image Edit execution command with the path to the model downloaded below.

Comfy-Org/Qwen-Image-Edit_ComfyUI at main
We’re on a journey to advance and democratize artificial intelligence through open source and open science.

The official documentation includes the --llm_vision flag when running Qwen Image Edit 2509, but adding this argument caused the execution to fail. (It might be an issue specific to my environment, though.)

Result

Creation Time : 2034.03s

It might just be a coincidence, but Qwen Image Edit 2509 handled “Close eyes” quite well.

comment

Copied title and URL