5 releases

0.1.9 Mar 8, 2024
0.1.8 Mar 8, 2024
0.1.7 Mar 7, 2024
0.1.6 Mar 7, 2024
0.1.5 Mar 3, 2024

#410 in Machine learning

Download history 468/week @ 2024-03-03 61/week @ 2024-03-10 3/week @ 2024-03-17 61/week @ 2024-03-24 14/week @ 2024-03-31

75 downloads per month
Used in stable-diffusion-cli

Apache-2.0

35KB
598 lines

Disclaimer Stable Diffusion is a trademark owned by Stability AI. Original repos: Stable Diffusion 1.5, Stable Diffusion 2.1, Stable Diffusion XL and XL-Turbo

Stable Diffusion

This is the Stable Diffusion core library.

Supported Versions

  • Stable Diffusion 1.5
  • Stable Diffusion 2.1
  • Stable Diffusion XL
  • Stable Diffusion Turbo

Backends

  • Cuda (default rust-feature)
  • Metal
  • Onnx
  • CPU

Examples

Image generation

use candle::Device;
use stable_diffusion::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let device = Device::new_cuda(0)?;
    let weights = StableDiffusionWeights::new(StableDiffusionVersion::XL, DType::F32);
    let parameters = StableDiffusionParameters::new(weights, device, DType::F16)?;
    let stable_diffusion = StableDiffusion::new(parameters)?;
    let args = GenerationParameters::new("A green apple");
    let image = stable_diffusion.generate(args)?;
    image.save("output.png")?;
    Ok(())
}

Dependencies

~44–61MB
~1M SLoC