Text-to-image generation that runs entirely in the browser.
Uses danyalmalik/small-sd-ONNX-WebGPU exported to ONNX, based off of segmind/small-sd. The .NET app is only a static host. It serves the page, the runtime files and the model files. Everything happens locally in your browser.
On first start the host downloads the models (about 1.6 GB) into models/ from Hugging Face. The browser then caches
them with the Cache API.
docker compose up --build
models volume on first start, so later
starts skip the download. Use localhost (or HTTPS) in the address: browsers only enable WebGPU in a secure context.
TODOnet10.0)The project has no NuGet package references. Everything above is part of the .NET shared framework.
| Dependency | Version | License | Location |
|---|---|---|---|
| onnxruntime-web | 1.29.0 | MIT | wwwroot/lib/onnxruntime-web/ (self-hosted, no CDN) |
Files used from onnxruntime-web:
ort.webgpu.min.mjs (66 KB): the runtime ES module.ort-wasm-simd-threaded.asyncify.mjs (51 KB) and .wasm (25 MB): the WebAssembly runtime, used by every backend.There are no other JavaScript libraries, bundlers or npm install steps. The app code is plain ES modules:
wwwroot/js/browser-sd.js: the CLIP tokenizer, DPM-Solver++ scheduler and diffusion pipeline.wwwroot/js/device-check.js: device detection, requirement checks and CPU time estimates.The page itself is wwwroot/index.html.
| Item | Source | Size |
|---|---|---|
| Text encoder (fp16 weights) | danyalmalik/small-sd-ONNX-WebGPU text_encoder/model.onnx | 246 MB |
| UNet (fp16 weights) | same repo, unet/model.onnx | 1.16 GB |
| VAE decoder (fp32) | same repo, vae_decoder/model.onnx | 198 MB |
| Tokenizer | same repo, tokenizer/vocab.json, tokenizer/merges.txt | 1.6 MB |
To change the repository or the download folder, edit the StableDiffusion section in
appsettings.json. For the model's license, see the model cards on Hugging Face.
| Feature | Needed for |
|---|---|
WebGPU with shader-f16 | GPU backend (fastest) |
WebNN (navigator.ml, GPU device) | DirectML backend on Windows. Experimental: in Chrome, enable --enable-features=WebMachineLearningNeuralNetwork |
WebAssembly SIMD + threads (SharedArrayBuffer) | CPU backend. Threads need cross-origin isolation, which the host turns on with COOP/COEP headers |
| Web Workers | Run CPU inference off the main thread (ONNX Runtime proxy worker) |
| Cache API, Storage API | Cache the model files and check free disk space |
| Canvas | Turn the output into PNG |
The page detects which of these are available and shows whether the device meets the requirements.
Content type
Image
Digest
sha256:e3cc39e7e…
Size
108.3 MB
Last updated
3 days ago
docker pull xavierh/small-x-studio