<a name="top"></a>
<h1 align="center">
diffusion-rs
</h1>
<h3 align="center">
Blazingly fast inference of diffusion models.
</h3>
<p align="center">
| <a href="https://ericlbuehler.github.io/diffusion-rs/diffusion_rs_core/"><b>Rust Documentation</b></a> | <a href="https://ericlbuehler.github.io/diffusion-rs/pyo3/diffusion_rs.html"><b>Python Documentation</b></a> | <a href="https://discord.gg/DRcvs6z5vu"><b>Discord</b></a> |
</p>
## Features
- Quantization
- `bitsandbytes` format (fp4, nf4, and int8)
- `GGUF` (2-8 bit quantization)
- Easy: Strong support for running [🤗 DDUF](https://huggingface.co/DDUF) models.
- Strong Apple Silicon support: support for the Metal, Accelerate, and ARM NEON frameworks
- Support for NVIDIA GPUs with CUDA
- AVX support for x86 CPUs
- Allow acceleration of models larger than the total VRAM size with offloading
Please do not hesitate to contact us with feature requests via [Github issues](https://github.com/EricLBuehler/diffusion-rs/issues)!
## Upcoming features
- 🚧 LoRA support
- 🚧 CPU + GPU inference with automatic offloading to allow partial acceleration of models larger than the total VRAM
## Installation
Check out the [installation guide](INSTALL.md) for details about installation.
## Examples
After [installing](#installation), you can try out these examples!
> Download the DDUF file here: `wget https://huggingface.co/DDUF/FLUX.1-dev-DDUF/resolve/main/FLUX.1-dev-Q4-bnb.dduf`
**CLI:**
```bash
diffusion_rs_cli --scale 3.5 --num-steps 50 dduf -f FLUX.1-dev-Q4-bnb.dduf
```
More CLI examples [here](diffusion_rs_cli/README.md).
**Python:**
More Python examples [here](diffusion_rs_py/examples).
```py
from diffusion_rs import DiffusionGenerationParams, ModelSource, Pipeline
from PIL import Image
import io
pipeline = Pipeline(source=ModelSource.DdufFile("FLUX.1-dev-Q4-bnb.dduf"))
image_bytes = pipeline.forward(
prompts=["Draw a picture of a sunrise."],
params=DiffusionGenerationParams(
height=720, width=1280, num_steps=50, guidance_scale=3.5
),
)
image = Image.open(io.BytesIO(image_bytes[0]))
image.show()
```
**Rust crate:**
Examples with the Rust crate: [here](diffusion_rs_examples/examples).
```rust
use std::time::Instant;
use diffusion_rs_core::{DiffusionGenerationParams, ModelSource, Offloading, Pipeline, TokenSource};
use tracing::level_filters::LevelFilter;
use tracing_subscriber::EnvFilter;
let filter = EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy();
tracing_subscriber::fmt().with_env_filter(filter).init();
let pipeline = Pipeline::load(
ModelSource::dduf("FLUX.1-dev-Q4-bnb.dduf")?,
false,
TokenSource::CacheToken,
None,
None,
)?;
let start = Instant::now();
let images = pipeline.forward(
vec!["Draw a picture of a sunrise.".to_string()],
DiffusionGenerationParams {
height: 720,
width: 1280,
num_steps: 50,
guidance_scale: 3.5,
},
)?;
let end = Instant::now();
println!("Took: {:.2}s", end.duration_since(start).as_secs_f32());
images[0].save("image.png")?;
```
## Support matrix
| Model | Supports DDUF | Supports quantized DDUF |
| -- | -- | -- |
| FLUX.1 Dev/Schnell | ✅ | ✅ |
## Contributing
- Anyone is welcome to contribute by opening PRs
- See [good first issues](https://github.com/EricLBuehler/diffusion-rs/labels/good%20first%20issue) for a starting point!
- Collaborators will be invited based on past contributions
Raw data
{
"_id": null,
"home_page": "https://github.com/EricLBuehler/diffusion-rs",
"name": "diffusion-rs-metal",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "machine-learning",
"author": "Eric Buehler",
"author_email": null,
"download_url": null,
"platform": null,
"description": "<a name=\"top\"></a>\n<h1 align=\"center\">\n diffusion-rs\n</h1>\n\n<h3 align=\"center\">\nBlazingly fast inference of diffusion models.\n</h3>\n\n<p align=\"center\">\n| <a href=\"https://ericlbuehler.github.io/diffusion-rs/diffusion_rs_core/\"><b>Rust Documentation</b></a> | <a href=\"https://ericlbuehler.github.io/diffusion-rs/pyo3/diffusion_rs.html\"><b>Python Documentation</b></a> | <a href=\"https://discord.gg/DRcvs6z5vu\"><b>Discord</b></a> |\n</p>\n\n\n## Features\n- Quantization\n - `bitsandbytes` format (fp4, nf4, and int8)\n - `GGUF` (2-8 bit quantization)\n- Easy: Strong support for running [\ud83e\udd17 DDUF](https://huggingface.co/DDUF) models.\n- Strong Apple Silicon support: support for the Metal, Accelerate, and ARM NEON frameworks\n- Support for NVIDIA GPUs with CUDA\n- AVX support for x86 CPUs\n- Allow acceleration of models larger than the total VRAM size with offloading\n\nPlease do not hesitate to contact us with feature requests via [Github issues](https://github.com/EricLBuehler/diffusion-rs/issues)!\n\n## Upcoming features\n- \ud83d\udea7 LoRA support\n- \ud83d\udea7 CPU + GPU inference with automatic offloading to allow partial acceleration of models larger than the total VRAM\n\n## Installation\nCheck out the [installation guide](INSTALL.md) for details about installation.\n\n## Examples\nAfter [installing](#installation), you can try out these examples!\n\n> Download the DDUF file here: `wget https://huggingface.co/DDUF/FLUX.1-dev-DDUF/resolve/main/FLUX.1-dev-Q4-bnb.dduf`\n\n**CLI:**\n```bash\ndiffusion_rs_cli --scale 3.5 --num-steps 50 dduf -f FLUX.1-dev-Q4-bnb.dduf\n```\n\nMore CLI examples [here](diffusion_rs_cli/README.md).\n\n**Python:**\n\nMore Python examples [here](diffusion_rs_py/examples).\n\n```py\nfrom diffusion_rs import DiffusionGenerationParams, ModelSource, Pipeline\nfrom PIL import Image\nimport io\n\npipeline = Pipeline(source=ModelSource.DdufFile(\"FLUX.1-dev-Q4-bnb.dduf\"))\n\nimage_bytes = pipeline.forward(\n prompts=[\"Draw a picture of a sunrise.\"],\n params=DiffusionGenerationParams(\n height=720, width=1280, num_steps=50, guidance_scale=3.5\n ),\n)\n\nimage = Image.open(io.BytesIO(image_bytes[0]))\nimage.show()\n```\n\n**Rust crate:**\n\nExamples with the Rust crate: [here](diffusion_rs_examples/examples).\n\n```rust\nuse std::time::Instant;\n\nuse diffusion_rs_core::{DiffusionGenerationParams, ModelSource, Offloading, Pipeline, TokenSource};\nuse tracing::level_filters::LevelFilter;\nuse tracing_subscriber::EnvFilter;\n\nlet filter = EnvFilter::builder()\n .with_default_directive(LevelFilter::INFO.into())\n .from_env_lossy();\ntracing_subscriber::fmt().with_env_filter(filter).init();\n\nlet pipeline = Pipeline::load(\n ModelSource::dduf(\"FLUX.1-dev-Q4-bnb.dduf\")?,\n false,\n TokenSource::CacheToken,\n None,\n None,\n)?;\n\nlet start = Instant::now();\n\nlet images = pipeline.forward(\n vec![\"Draw a picture of a sunrise.\".to_string()],\n DiffusionGenerationParams {\n height: 720,\n width: 1280,\n num_steps: 50,\n guidance_scale: 3.5,\n },\n)?;\n\nlet end = Instant::now();\nprintln!(\"Took: {:.2}s\", end.duration_since(start).as_secs_f32());\n\nimages[0].save(\"image.png\")?;\n```\n\n## Support matrix\n| Model | Supports DDUF | Supports quantized DDUF |\n| -- | -- | -- |\n| FLUX.1 Dev/Schnell | \u2705 | \u2705 |\n\n## Contributing\n\n- Anyone is welcome to contribute by opening PRs\n - See [good first issues](https://github.com/EricLBuehler/diffusion-rs/labels/good%20first%20issue) for a starting point!\n- Collaborators will be invited based on past contributions\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Blazingly fast inference of diffusion models.",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/EricLBuehler/diffusion-rs",
"Source Code": "https://github.com/EricLBuehler/diffusion-rs"
},
"split_keywords": [
"machine-learning"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4369b566ef2dddcb5b99f6a757334f0e67aaf905e27213b70964db4b256100ad",
"md5": "acbfdea836ad6368945a153d2ee66dca",
"sha256": "f8de2cf0ecc5e47d89c61b95b333162a753e7b3a342ace6c0947bed504d7ab41"
},
"downloads": -1,
"filename": "diffusion_rs_metal-0.1.0-cp310-cp310-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "acbfdea836ad6368945a153d2ee66dca",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 5698499,
"upload_time": "2025-01-07T12:40:40",
"upload_time_iso_8601": "2025-01-07T12:40:40.943458Z",
"url": "https://files.pythonhosted.org/packages/43/69/b566ef2dddcb5b99f6a757334f0e67aaf905e27213b70964db4b256100ad/diffusion_rs_metal-0.1.0-cp310-cp310-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a0e77b59d4a1020198b30181b989a6303c36d8eb8465990f01bb9e7435b0909d",
"md5": "2c9eeaa6275cddd59fe4de6a887a03d4",
"sha256": "a2ddcead867a9a0115450daaff83252aae13624ea1793016abdaa29df329fd10"
},
"downloads": -1,
"filename": "diffusion_rs_metal-0.1.0-cp311-cp311-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "2c9eeaa6275cddd59fe4de6a887a03d4",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.10",
"size": 5698688,
"upload_time": "2025-01-07T12:40:46",
"upload_time_iso_8601": "2025-01-07T12:40:46.781764Z",
"url": "https://files.pythonhosted.org/packages/a0/e7/7b59d4a1020198b30181b989a6303c36d8eb8465990f01bb9e7435b0909d/diffusion_rs_metal-0.1.0-cp311-cp311-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fbec507ed49f0750c3087afd0dcbca2045f9fa728a7ffa09f16c958f1e3b1d9a",
"md5": "76a0f38822a018f3ee86837d42d927b2",
"sha256": "06126cce83fb9c82bd46b0c6e6dce148d021c5057404fe1a6d890fa4dc707c7b"
},
"downloads": -1,
"filename": "diffusion_rs_metal-0.1.0-cp312-cp312-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "76a0f38822a018f3ee86837d42d927b2",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.10",
"size": 5694871,
"upload_time": "2025-01-07T12:40:50",
"upload_time_iso_8601": "2025-01-07T12:40:50.554006Z",
"url": "https://files.pythonhosted.org/packages/fb/ec/507ed49f0750c3087afd0dcbca2045f9fa728a7ffa09f16c958f1e3b1d9a/diffusion_rs_metal-0.1.0-cp312-cp312-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-07 12:40:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "EricLBuehler",
"github_project": "diffusion-rs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "diffusion-rs-metal"
}