diffusion-rs


Namediffusion-rs JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/EricLBuehler/diffusion-rs
SummaryBlazingly fast inference of diffusion models.
upload_time2025-01-07 12:39:00
maintainerNone
docs_urlNone
authorEric Buehler
requires_python>=3.10
licenseMIT
keywords machine-learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <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",
    "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": "f506af68a2b0ffb30452a209dde918aaeb73f596d1f0caae061afcf8d81cbf39",
                "md5": "3df92d22521b423c4e01bc173e84e9cc",
                "sha256": "c32ddca2a4dbdb692809b94c359f7c83528bb6c3ff4e3d63dd989dcd43967426"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp310-cp310-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "3df92d22521b423c4e01bc173e84e9cc",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10",
            "size": 5418246,
            "upload_time": "2025-01-07T12:39:00",
            "upload_time_iso_8601": "2025-01-07T12:39:00.779810Z",
            "url": "https://files.pythonhosted.org/packages/f5/06/af68a2b0ffb30452a209dde918aaeb73f596d1f0caae061afcf8d81cbf39/diffusion_rs-0.1.0-cp310-cp310-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5dde51e5c74c5c88c8af2deded924f11139ddae2121b7b59a8168bd02477012d",
                "md5": "56cd692fa0e8a765a6fce1a9e2a73aa1",
                "sha256": "31b65637ed35d45dca195664c3d153b93ba42676fb3432459b669768fea9a18d"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "56cd692fa0e8a765a6fce1a9e2a73aa1",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10",
            "size": 8029013,
            "upload_time": "2025-01-07T12:39:04",
            "upload_time_iso_8601": "2025-01-07T12:39:04.594235Z",
            "url": "https://files.pythonhosted.org/packages/5d/de/51e5c74c5c88c8af2deded924f11139ddae2121b7b59a8168bd02477012d/diffusion_rs-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca2125ce19356628c59439228f033bbea16f763603407ca0d0695ce2049a5d87",
                "md5": "c9b89f9b8a1b8eccfc19071ce48c7930",
                "sha256": "26958347d98802331948ddb44ea48a1c25d9ea3943353d84b9a5505805614b0f"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl",
            "has_sig": false,
            "md5_digest": "c9b89f9b8a1b8eccfc19071ce48c7930",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10",
            "size": 8745843,
            "upload_time": "2025-01-07T12:39:09",
            "upload_time_iso_8601": "2025-01-07T12:39:09.670632Z",
            "url": "https://files.pythonhosted.org/packages/ca/21/25ce19356628c59439228f033bbea16f763603407ca0d0695ce2049a5d87/diffusion_rs-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4ebac0801b713fe8852d03a993be04c962d3f0a2dfe5ca5d0eebb1a86b105d83",
                "md5": "2042bb465f594f760199be6896b88723",
                "sha256": "538de3a4994c5cb634f0ddbde92109bfa19a9232abc139f9ae47b19afa1513c4"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp310-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "2042bb465f594f760199be6896b88723",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10",
            "size": 5431140,
            "upload_time": "2025-01-07T12:39:13",
            "upload_time_iso_8601": "2025-01-07T12:39:13.132857Z",
            "url": "https://files.pythonhosted.org/packages/4e/ba/c0801b713fe8852d03a993be04c962d3f0a2dfe5ca5d0eebb1a86b105d83/diffusion_rs-0.1.0-cp310-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "abe02fdfc1cc6df633251435025079a88d8a8fa2b22eb07fa226c3641f9824e0",
                "md5": "90fed5e78568df49d2a3d8a67da957d4",
                "sha256": "6bfbbc68784773f81980f6e90677ec318c85a60c308c87da87021d8c361becae"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "90fed5e78568df49d2a3d8a67da957d4",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10",
            "size": 5418416,
            "upload_time": "2025-01-07T12:39:16",
            "upload_time_iso_8601": "2025-01-07T12:39:16.777310Z",
            "url": "https://files.pythonhosted.org/packages/ab/e0/2fdfc1cc6df633251435025079a88d8a8fa2b22eb07fa226c3641f9824e0/diffusion_rs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fa5742e9fb08cb2b41b1060e071fffe9c48da0e2a8564d57379376391b3f4154",
                "md5": "549dda506cd083d2368236c245edbb8d",
                "sha256": "9f5b71b24e4a1d672930af16817e023e0afc72c4118eede3477d4a301ac06643"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "549dda506cd083d2368236c245edbb8d",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10",
            "size": 8028151,
            "upload_time": "2025-01-07T12:39:20",
            "upload_time_iso_8601": "2025-01-07T12:39:20.334856Z",
            "url": "https://files.pythonhosted.org/packages/fa/57/42e9fb08cb2b41b1060e071fffe9c48da0e2a8564d57379376391b3f4154/diffusion_rs-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "edb4efac28d4649ea4fe20746082b77d118dab68ff0233b5c13b705a84ee36e4",
                "md5": "8743e44b35ae87981edabc150db3dfe8",
                "sha256": "110f1c0bd357e158bae1de361a815576b780d6550291221de7a52aa2e8cfad20"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl",
            "has_sig": false,
            "md5_digest": "8743e44b35ae87981edabc150db3dfe8",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10",
            "size": 8744514,
            "upload_time": "2025-01-07T12:39:23",
            "upload_time_iso_8601": "2025-01-07T12:39:23.374483Z",
            "url": "https://files.pythonhosted.org/packages/ed/b4/efac28d4649ea4fe20746082b77d118dab68ff0233b5c13b705a84ee36e4/diffusion_rs-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4ef7c61f839852a985ae18739135ddb3dc2340309c55231e761791c0d1a09fc4",
                "md5": "c10c37f9f081eb4fa8017fa893b07ca4",
                "sha256": "6479b62382baf42bdf18160504787c9d685f45294472e339fe0f406fc6e60cc3"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp311-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "c10c37f9f081eb4fa8017fa893b07ca4",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10",
            "size": 5431262,
            "upload_time": "2025-01-07T12:39:27",
            "upload_time_iso_8601": "2025-01-07T12:39:27.590277Z",
            "url": "https://files.pythonhosted.org/packages/4e/f7/c61f839852a985ae18739135ddb3dc2340309c55231e761791c0d1a09fc4/diffusion_rs-0.1.0-cp311-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d0e4adb0eb7ad7df51c64b30934cfdc7266506361c6dba2a048c3a873e5d0a42",
                "md5": "01f8525f5f2985848066921bb0c317d0",
                "sha256": "4f432430fc5c32cac77a187989c7f7bdb668549103d77f98e3aac0f8bdbd744d"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "01f8525f5f2985848066921bb0c317d0",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.10",
            "size": 5416928,
            "upload_time": "2025-01-07T12:39:30",
            "upload_time_iso_8601": "2025-01-07T12:39:30.477705Z",
            "url": "https://files.pythonhosted.org/packages/d0/e4/adb0eb7ad7df51c64b30934cfdc7266506361c6dba2a048c3a873e5d0a42/diffusion_rs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e2ba1d1e91f34957f38366ae848ed7ba1368a02203152b69095441f5d1040e72",
                "md5": "ff9e2d069a59aeb8c8d14b6179d95a83",
                "sha256": "ad6ecdeb95d6733ab6d5bc89111f0433bea647e9f532485c0ea8ccbc2ea2a565"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "ff9e2d069a59aeb8c8d14b6179d95a83",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.10",
            "size": 8027049,
            "upload_time": "2025-01-07T12:39:33",
            "upload_time_iso_8601": "2025-01-07T12:39:33.646345Z",
            "url": "https://files.pythonhosted.org/packages/e2/ba/1d1e91f34957f38366ae848ed7ba1368a02203152b69095441f5d1040e72/diffusion_rs-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d016f624135eacf4b528dd7e15542ad31183834923700194ce141bfa25d9e287",
                "md5": "f313462008f8c2e9e9fe0404286ab6d9",
                "sha256": "08fe7d359acb3e08c6ed04c3c1fc82af32fd6c2455bc9acc6d48df2b4c489b75"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl",
            "has_sig": false,
            "md5_digest": "f313462008f8c2e9e9fe0404286ab6d9",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.10",
            "size": 8750138,
            "upload_time": "2025-01-07T12:39:37",
            "upload_time_iso_8601": "2025-01-07T12:39:37.955197Z",
            "url": "https://files.pythonhosted.org/packages/d0/16/f624135eacf4b528dd7e15542ad31183834923700194ce141bfa25d9e287/diffusion_rs-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f25accde9c698785ad6401ad97e93447b444e30d4c6091ee3c60504cf84b315b",
                "md5": "734f26c122fa9955f324dc08fbdd13f3",
                "sha256": "0570a8e0cb70ae94a95459a779071ef89d478a6cc6d9740da8cf76eda8a049b4"
            },
            "downloads": -1,
            "filename": "diffusion_rs-0.1.0-cp312-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "734f26c122fa9955f324dc08fbdd13f3",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.10",
            "size": 5431295,
            "upload_time": "2025-01-07T12:39:42",
            "upload_time_iso_8601": "2025-01-07T12:39:42.729017Z",
            "url": "https://files.pythonhosted.org/packages/f2/5a/ccde9c698785ad6401ad97e93447b444e30d4c6091ee3c60504cf84b315b/diffusion_rs-0.1.0-cp312-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-07 12:39:00",
    "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"
}
        
Elapsed time: 2.34790s