Skip to main content
Use Qwen-Image 2.1 to create an image from a text prompt or edit an existing image.

Prepare the model

Download the model weights from Qwen/Qwen-Image-2.1 on Hugging Face. You need Python 3.12 or newer, uv, and NVIDIA GPUs with CUDA support. Run the following commands from the PhyAI repository root. Replace the checkpoint path with the folder where you saved the model:

Generate an image

This example uses two GPUs and saves a 512 x 512 PNG. Check available GPUs with nvidia-smi, then adjust CUDA_VISIBLE_DEVICES if needed.
Open .cache/qwen_image_21.png to view the result. The script creates the output folder automatically.

Edit an image

Set --image to your input image and describe the change in --prompt:
Repeat --image to provide multiple reference images, up to 10.

Common options

For one GPU, use CUDA_VISIBLE_DEVICES=0 and --tp 1. For eight GPUs, use CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 and --tp 8. To see all available options: