Skip to main content

Stable-Diffusion-v2.1 Example

This document explains how to use the QAI AppBuilder Python API to perform inference with the Stable-Diffusion-v2.1 text-to-image model using the Qualcomm® Hexagon™ Processor (NPU).

Supported devices

DeviceSoC
Fogwise® AIRbox Q900QCS9075

Install QAI AppBuilder​

tip
  1. Install QAI AppBuilder by following the QAI AppBuilder installation guide.

  2. Configure ADSP environment variables as described in Create ADSP environment variables.

Run the sample​

Install dependencies​

Install sample dependencies in the activated virtual environment:

Device
pip3 install requests tqdm qai-hub py3-wget Pillow torch torchvision opencv-python-headless transformers diffusers

Run the script​

  • Enter the upstream samples directory

    Device
    cd qai-appbuilder/samples
  • Prepare input data (use the sample input if provided, or pass script arguments)

Output image

  • Run inference

    Device
    python3 GenerativeAI/Image_Generation/stable_diffusion_v2_1/stable_diffusion_v2_1.py --chipset 9075 --prompt "a cat"

On success an image is written under the sample directory, for example:

GenerativeAI/Image_Generation/stable_diffusion_v2_1/images/<timestamp>_512.jpg

On AIRbox Q900 the first run downloads Text Encoder / UNet / VAE (on the order of ~1.2 GB total). Slow networks may take tens of minutes to hours.

tip

Requires transformers and diffusers. Prefer running the script directly (avoids run_inference.py --args quoting issues with spaces in prompts):

python3 GenerativeAI/Image_Generation/stable_diffusion_v2_1/stable_diffusion_v2_1.py --chipset 9075 --prompt "a cat"

    You need to be logged into GitHub to post a comment. If you are already logged in, please ignore this message.

    Radxa-docs © 2026 by Radxa Computer (Shenzhen) Co.,Ltd. is licensed under CC BY 4.0