跳到主要内容

Stable-Diffusion-v1.5 示例

此文档讲述使用 QAI AppBuilder Python API 利用 Qualcomm® Hexagon™ Processor (NPU) 推理 Stable-Diffusion-v1.5 文生图模型。

示例支持设备

设备SoC
Fogwise® AIRbox Q900QCS9075

安装 QAI AppBuilder

提示
  1. 请根据 QAI AppBuilder 安装方法 安装 QAI AppBuilder。

  2. 请根据 创建 ADSP 环境变量 配置 ADSP 环境变量。

运行示例

安装依赖

Device
pip3 install requests tqdm qai-hub py3_wget opencv-python torch torchvision matplotlib easyocr qai_hub_models transformers diffusers

运行脚本

  • 进入示例目录

    Device
    cd ai-engine-direct-helper/samples/python
  • 执行推理

    Device
    python3 stable_diffusion_v1_5/stable_diffusion_v1_5.py --prompt spectacular view of northern lights from Alaska
    $ python3 stable_diffusion_v1_5/stable_diffusion_v1_5.py --prompt spectacular view of northern lights from Alaska
    /prj/qct/webtech_scratch20/mlg_user_admin/qaisw_source_repo/rel/qairt-2.37.1/point_release/SNPE_SRC/avante-tools/prebuilt/dsp/hexagon-sdk-5.5.5/ipc/fastrpc/rpcmem/src/rpcmem_android.c:38:dummy call to rpcmem_init, rpcmem APIs will be used from libxdsprpc
    Step 0 Running...
    Step 1 Running...
    Step 2 Running...
    Step 3 Running...
    Step 4 Running...
    Step 5 Running...
    Step 6 Running...
    Step 7 Running...
    Step 8 Running...
    Step 9 Running...
    Step 10 Running...
    Step 11 Running...
    Step 12 Running...
    Step 13 Running...
    Step 14 Running...
    Step 15 Running...
    Step 16 Running...
    Step 17 Running...
    Step 18 Running...
    Step 19 Running...
    /mnt/ssd/qualcomm/702/zzf_fork/test/ai-engine-direct-helper/samples/python/stable_diffusion_v1_5/stable_diffusion_v1_5.py:255: DeprecationWarning: 'mode' parameter is deprecated and will be removed in Pillow 13 (2026-10-15)
    output_image = Image.fromarray(output_image, mode="RGB")
    Image saved to '/mnt/ssd/qualcomm/702/zzf_fork/test/ai-engine-direct-helper/samples/python/stable_diffusion_v1_5/images/2025_10_30_03_55_02_6303777164_512.jpg'
    time consumes for inference 5.059798002243042(s)
    <W> Logs will be sent to the system's default channel
    /usr/bin/xdg-open: 882: www-browser: not found
    /usr/bin/xdg-open: 882: links2: not found
    /usr/bin/xdg-open: 882: elinks: not found
    /usr/bin/xdg-open: 882: links: not found
    /usr/bin/xdg-open: 882: lynx: not found
    /usr/bin/xdg-open: 882: w3m: not found
    xdg-open: no method available for opening '/tmp/tmpyor75jks.PNG'
    <W> Logs will be sent to the system's default channel
    /prj/qct/webtech_scratch20/mlg_user_admin/qaisw_source_repo/rel/qairt-2.37.1/point_release/SNPE_SRC/avante-tools/prebuilt/dsp/hexagon-sdk-5.5.5/ipc/fastrpc/rpcmem/src/rpcmem_android.c:42:dummy call to rpcmem_deinit, rpcmem APIs will be used from libxdsprpc

    output image

    您需要登录 GitHub 才能发表评论。如果您已登录,请忽略此消息。

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