8 releases

0.1.7 Feb 8, 2025
0.1.6 Jan 18, 2025
0.1.4 Dec 28, 2024
0.1.3 Nov 14, 2024

#160 in Machine learning

Download history 251/week @ 2024-10-30 161/week @ 2024-11-06 145/week @ 2024-11-13 13/week @ 2024-11-20 2/week @ 2024-12-04 1/week @ 2024-12-11 81/week @ 2024-12-25 9/week @ 2025-01-01 8/week @ 2025-01-08 251/week @ 2025-01-15 141/week @ 2025-02-05

393 downloads per month

MIT license

4.5MB
91K SLoC

C 35K SLoC // 0.1% comments C++ 34K SLoC // 0.1% comments CUDA 8K SLoC // 0.0% comments Metal Shading Language 4.5K SLoC // 0.1% comments Objective-C 3.5K SLoC // 0.0% comments GLSL 2.5K SLoC // 0.0% comments Rust 2.5K SLoC // 0.0% comments Python 40 SLoC // 0.3% comments

diffusion-rs

Latest version Documentation

Rust bindings to https://github.com/leejet/stable-diffusion.cpp

Features Matrix

Windows Mac Linux
vulkan ✅️ ⛓️‍💥 ✅️
metal - ✅️ -
cuda ✅️ - ✅️
rocm ❔️ - ⛓️‍💥
sycl ❔️ - ✅️

✅️: Working

⛓️‍💥 : Issues when linking libraries

Usage

use diffusion_rs::{api::txt2img, preset::{Preset,PresetBuilder}};
let (mut config, mut model_config) = PresetBuilder::default()
            .preset(Preset::SDXLTurbo1_0Fp16)
            .prompt("a lovely duck drinking water from a bottle")
            .build()
            .unwrap();
txt2img(&mut config, &mut model_config).unwrap();

Troubleshooting

  • Something other than Windows/Linux isn't working!
    • I don't have a way to test these platforms, so I can't really help you.
  • I get a panic during binding generation build!
    • You can attempt to fix it yourself, or you can set the DIFFUSION_SKIP_BINDINGS environment variable. This skips attempting to build the bindings whatsoever and copies the existing ones. They may be out of date, but it's better than nothing.
      • DIFFUSION_SKIP_BINDINGS=1 cargo build
    • If you can fix the issue, please open a PR!

Roadmap

  1. Ensure that the underline cpp library compiles on supported platforms
  2. Build an easy to use library with model presets
  3. Automatic library publishing on crates.io by gh actions
  4. Maybe prebuilt CLI app binaries

Dependencies

~10–25MB
~305K SLoC