#stable-diffusion #wasm-edge #stable #executed #model

wasmedge_stable_diffusion

A Rust library for using stable diffusion functions when the Wasi is being executed on WasmEdge

7 releases

0.3.2 Oct 28, 2024
0.3.1 Oct 11, 2024
0.3.0 Sep 26, 2024
0.2.2 Sep 24, 2024
0.1.0 Aug 21, 2024

#246 in WebAssembly

Download history 110/week @ 2025-02-10 43/week @ 2025-02-17 123/week @ 2025-02-24 82/week @ 2025-03-03 127/week @ 2025-03-10 194/week @ 2025-03-17 62/week @ 2025-03-24 43/week @ 2025-03-31 124/week @ 2025-04-07 91/week @ 2025-04-14 47/week @ 2025-04-21 77/week @ 2025-04-28 23/week @ 2025-05-05 93/week @ 2025-05-12 72/week @ 2025-05-19 35/week @ 2025-05-26

229 downloads per month
Used in llama-core

Apache-2.0

38KB
1K SLoC

WasmEdge Stable Diffusion

A Rust library for using stable diffusion functions when the Wasi is being executed on WasmEdge.

Set up WasmEdge

git clone https://github.com/WasmEdge/WasmEdge.git
cd WasmEdge
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_TESTS=OFF -DWASMEDGE_PLUGIN_STABLEDIFFUSION=On
cmake --build build
cmake --install build

Download Model

Download the weights or quantized model from the following command.
You also can use our example to quantize the weights by yourself.

stable-diffusion v1.4: second-state/stable-diffusion-v-1-4-GGUF
stable-diffusion v1.5: second-state/stable-diffusion-v1-5-GGUF
stable-diffusion v2.1: second-state/stable-diffusion-2-1-GGUF

curl -L -O https://huggingface.co/second-state/stable-diffusion-v-1-4-GGUF/resolve/main/sd-v1-4.ckpt

curl -L -O https://huggingface.co/second-state/stable-diffusion-v-1-4-GGUF/resolve/main/stable-diffusion-v1-4-Q8_0.gguf

Run the example

cargo build --target wasm32-wasi --release
wasmedge --dir .:. ./target/wasm32-wasi/release/wasmedge_stable_diffusion_example.wasm

Then you can see the three new files.

  1. sd-v1-4-Q8_0.gguf: is the quantization of sd-v1-4
  2. output.png: an image with a cat
  3. output2.png: an image of a cat with blue eyes.

Dependencies

~210–650KB
~15K SLoC