Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Run Stable Diffusion on Snapdragon X Elite

Follow instructions to run the demo:

  1. Enable PowerShell Scripts. Open PowerShell in administrator mode, and run:
Set-ExecutionPolicy -Scope CurrentUser Unrestricted -Force
  1. Open Anaconda PowerShell Prompt in this folder. If you don't have Anaconda PowerShell, use regular PowerShell.

  2. Install platform dependencies:

..\install_platform_deps.ps1

The above script will install:

  • Anaconda for x86-64. We use x86-64 Python for compatibility with other Python packages. However, inference in ONNX Runtime will, for the most part, run natively with ARM64 code.
  • Git for Windows. This is required to load the AI Hub Models package, which contains the application code used by this demo.
  1. Open (or re-open) Anaconda Powershell Prompt to continue.

  2. Create & activate your python environment:

..\activate_venv.ps1 -name AI_Hub
  1. Install python packages:
..\install_python_deps.ps1 -model stable-diffusion-v2-1

In your currently active python environment, the above script will install:

  • AI Hub Models and model dependencies for stable diffusion.
  • The onnxruntime-qnn package, both to enable native ARM64 ONNX inference, as well as to enable targeting Qualcomm NPUs.
  1. Download the PRECOMPILED_QNN_ONNX model files from Qualcomm HuggingFace Repo based on your target device, e.g., X-Elite users choose Snapdragon® X Elite.

  2. Extract the zip to <APP ROOT>/model directory. The expected directory structure is:

model/
  |_ metadata.yaml
  |_ text_encoder.onnx
  |_ text_encoder_qairt_context.bin
  |_ unet.onnx
  |_ unet_qairt_context.bin
  |_ vae.onnx
  |_ vae_qairt_context.bin
  1. Run demo:
python demo.py --prompt "A girl taking a walk at sunset" --num-steps 20