Rust implementation of the Diffusers API for generative models
Top 57.5% on sourcepulse
This Rust implementation of the Hugging Face Diffusers API provides a native alternative for running Stable Diffusion models. It targets developers and researchers seeking to integrate diffusion models into Rust applications or explore their capabilities without Python dependencies. The library leverages the tch
crate for PyTorch bindings, enabling efficient execution on both CPU and GPU.
How It Works
The project directly implements the core components of the Stable Diffusion pipeline, including the U-Net, VAE, and CLIP text encoder, using Rust and tch
. It supports various schedulers like DDIM and allows for image-to-image generation and inpainting by loading specific model weights and masks. The architecture is designed for flexibility, enabling users to specify which components run on the CPU or GPU to manage memory constraints.
Quick Start & Requirements
cargo install
.libtorch
(PyTorch C++ API), and model weights downloaded from Hugging Face.cargo run --example stable-diffusion --features clap -- --prompt "A rusty robot holding a fire torch."
python3 ./scripts/get_weights.py
Highlighted Details
PYTORCH_CUDA_ALLOC_CONF
).Maintenance & Community
Licensing & Compatibility
tch
crate is typically MIT licensed, but the project's specific licensing requires verification.tch
crate license and any potential restrictions on model weights.Limitations & Caveats
The project requires manual downloading and placement of model weights. Memory optimization for GPUs with less than 8GB VRAM is complex, involving fp16 weights and specific component offloading. ControlNet requires additional specific weights.
1 year ago
1 day