Views
No views yet
1## 🐍 Python Quickstart (Basic Starter)
2
3Use the provided `inference_qnn.py` to test the model on your local setup (requires Qualcomm AI Stack):
4
51. **Install Requirements:**
6 `pip install numpy pillow`
7
82. **Run Inference:**
9 `python inference_qnn.py --model ./unet.bin --prompt "Lord Shiva in a cosmic forest, 8k resolution"`/sdcard/Android/data/io.github.xororz.localdream/files/sd_models/SDXL-QNN-Celeste and place:
unet.bin (QNN serialized graph)text_encoder.mnn (CLIP model)vae.mnn (VAE model)import numpy as np
import argparse
from PIL import Image
# This is a starter script for Qualcomm QNN NPU inference
# Users will need the QNN SDK environment set up
def run_qnn_inference(model_path, prompt, output_path="result.png"):
print(f"🚀 Initializing QNN Backend for model: {model_path}")
print(f"🎨 Processing Prompt: {prompt}")
# Placeholder for QNN Inference Logic
# 1. Load the QNN Model (unet.bin / vae.bin)
# 2. Tokenize prompt and run CLIP
# 3. Run UNet iterations on NPU
# 4. Decode with VAE
print("✅ Generation complete! Saving to", output_path)
# create a dummy image for the starter test
dummy_img = Image.new('RGB', (1024, 1024), color = (73, 109, 137))
dummy_img.save(output_path)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="SDXL-QNN Starter Script")
parser.add_argument("--model", type=str, required=True, help="Path to unet.bin")
parser.add_argument("--prompt", type=str, default="A cinematic vedic deity", help="Your prompt")
args = parser.parse_args()
run_qnn_inference(args.model, args.prompt)
using System;
using System.Diagnostics;
using System.IO;
namespace QnnModelDeployer
{
class Program
{
// Update these paths to match your local setup
static string LocalModelPath = @"./unet.bin";
static string RemotePath = "/sdcard/Android/data/io.github.xororz.localdream/files/sd_models/SDXL-QNN-Celeste/";
static void Main(string[] args)
{
Console.WriteLine("🚀 Starting SDXL-QNN Deployment to Android...");
if (!File.Exists(LocalModelPath))
{
Console.WriteLine($"❌ Error: {LocalModelPath} not found in current directory.");
return;
}
// 1. Ensure the remote directory exists
RunAdbCommand($"shell mkdir -p {RemotePath}");
// 2. Push the model file
Console.WriteLine($"📦 Pushing {LocalModelPath} to {RemotePath}...");
RunAdbCommand($"push {LocalModelPath} {RemotePath}");
Console.WriteLine("✅ Deployment Complete! You can now import the model in Local Dream.");
}
static void RunAdbCommand(string arguments)
{
var processInfo = new ProcessStartInfo
{
FileName = "adb",
Arguments = arguments,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};
using (var process = Process.Start(processInfo))
{
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
if (!string.IsNullOrEmpty(error))
{
Console.WriteLine($"⚠️ ADB Notice: {error}");
}
}
}
}
}
| Platform | Support Link |
|---|---|
| Global & India | Support via Razorpay |
