Crates.io | stable-diffusion |
lib.rs | stable-diffusion |
version | 0.1.9 |
source | src |
created_at | 2024-03-03 02:36:58.033978 |
updated_at | 2024-03-08 22:05:43.120238 |
description | Stable Diffusion |
homepage | https://github.com/sensorial-systems/stable-diffusion |
repository | https://github.com/sensorial-systems/stable-diffusion |
max_upload_size | |
id | 1160194 |
size | 34,559 |
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
This is the Stable Diffusion core library.
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(())
}