text stringlengths 3 14.4k | source stringclasses 273
values | url stringlengths 47 172 | source_section stringlengths 0 95 | file_type stringclasses 1
value | id stringlengths 3 6 |
|---|---|---|---|---|---|
The training script has many parameters to help you tailor the training run to your needs. All of the parameters and their descriptions are listed in the [`parse_args()`](https://github.com/huggingface/diffusers/blob/839c2a5ece0af4e75530cb520d77bc7ed8acf474/examples/textual_inversion/textual_inversion.py#L176) function... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/text_inversion.md | https://huggingface.co/docs/diffusers/en/training/text_inversion/#script-parameters | #script-parameters | .md | 32_2 |
Unlike some of the other training scripts, textual_inversion.py has a custom dataset class, [`TextualInversionDataset`](https://github.com/huggingface/diffusers/blob/b81c69e489aad3a0ba73798c459a33990dc4379c/examples/textual_inversion/textual_inversion.py#L487) for creating a dataset. You can customize the image size, p... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/text_inversion.md | https://huggingface.co/docs/diffusers/en/training/text_inversion/#training-script | #training-script | .md | 32_3 |
Once you've made all your changes or you're okay with the default configuration, you're ready to launch the training script! 🚀
For this guide, you'll download some images of a [cat toy](https://huggingface.co/datasets/diffusers/cat_toy_example) and store them in a directory. But remember, you can create and use your... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/text_inversion.md | https://huggingface.co/docs/diffusers/en/training/text_inversion/#launch-the-script | #launch-the-script | .md | 32_4 |
Congratulations on training your own Textual Inversion model! 🎉 To learn more about how to use your new model, the following guides may be helpful:
- Learn how to [load Textual Inversion embeddings](../using-diffusers/loading_adapters) and also use them as negative embeddings.
- Learn how to use [Textual Inversion](... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/text_inversion.md | https://huggingface.co/docs/diffusers/en/training/text_inversion/#next-steps | #next-steps | .md | 32_5 |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/ddpo.md | https://huggingface.co/docs/diffusers/en/training/ddpo/ | .md | 33_0 | |
You can fine-tune Stable Diffusion on a reward function via reinforcement learning with the 🤗 TRL library and 🤗 Diffusers. This is done with the Denoising Diffusion Policy Optimization (DDPO) algorithm introduced by Black et al. in [Training Diffusion Models with Reinforcement Learning](https://arxiv.org/abs/2305.133... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/ddpo.md | https://huggingface.co/docs/diffusers/en/training/ddpo/#reinforcement-learning-training-with-ddpo | #reinforcement-learning-training-with-ddpo | .md | 33_1 |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/t2i_adapters.md | https://huggingface.co/docs/diffusers/en/training/t2i_adapters/ | .md | 34_0 | |
[T2I-Adapter](https://hf.co/papers/2302.08453) is a lightweight adapter model that provides an additional conditioning input image (line art, canny, sketch, depth, pose) to better control image generation. It is similar to a ControlNet, but it is a lot smaller (~77M parameters and ~300MB file size) because its only ins... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/t2i_adapters.md | https://huggingface.co/docs/diffusers/en/training/t2i_adapters/#t2i-adapter | #t2i-adapter | .md | 34_1 |
The training script provides many parameters to help you customize your training run. All of the parameters and their descriptions are found in the [`parse_args()`](https://github.com/huggingface/diffusers/blob/aab6de22c33cc01fb7bc81c0807d6109e2c998c9/examples/t2i_adapter/train_t2i_adapter_sdxl.py#L233) function. It pr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/t2i_adapters.md | https://huggingface.co/docs/diffusers/en/training/t2i_adapters/#script-parameters | #script-parameters | .md | 34_2 |
As with the script parameters, a walkthrough of the training script is provided in the [Text-to-image](text2image#training-script) training guide. Instead, this guide takes a look at the T2I-Adapter relevant parts of the script.
The training script begins by preparing the dataset. This incudes [tokenizing](https://gi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/t2i_adapters.md | https://huggingface.co/docs/diffusers/en/training/t2i_adapters/#training-script | #training-script | .md | 34_3 |
Now you’re ready to launch the training script! 🚀
For this example training, you'll use the [fusing/fill50k](https://huggingface.co/datasets/fusing/fill50k) dataset. You can also create and use your own dataset if you want (see the [Create a dataset for training](https://moon-ci-docs.huggingface.co/docs/diffusers/pr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/t2i_adapters.md | https://huggingface.co/docs/diffusers/en/training/t2i_adapters/#launch-the-script | #launch-the-script | .md | 34_4 |
Congratulations on training a T2I-Adapter model! 🎉 To learn more:
- Read the [Efficient Controllable Generation for SDXL with T2I-Adapters](https://huggingface.co/blog/t2i-sdxl-adapters) blog post to learn more details about the experimental results from the T2I-Adapter team. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/t2i_adapters.md | https://huggingface.co/docs/diffusers/en/training/t2i_adapters/#next-steps | #next-steps | .md | 34_5 |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/lcm_distill.md | https://huggingface.co/docs/diffusers/en/training/lcm_distill/ | .md | 35_0 | |
[Latent Consistency Models (LCMs)](https://hf.co/papers/2310.04378) are able to generate high-quality images in just a few steps, representing a big leap forward because many pipelines require at least 25+ steps. LCMs are produced by applying the latent consistency distillation method to any Stable Diffusion model. Thi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/lcm_distill.md | https://huggingface.co/docs/diffusers/en/training/lcm_distill/#latent-consistency-distillation | #latent-consistency-distillation | .md | 35_1 |
<Tip>
The following sections highlight parts of the training script that are important for understanding how to modify it, but it doesn't cover every aspect of the script in detail. If you're interested in learning more, feel free to read through the [script](https://github.com/huggingface/diffusers/blob/main/example... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/lcm_distill.md | https://huggingface.co/docs/diffusers/en/training/lcm_distill/#script-parameters | #script-parameters | .md | 35_2 |
The training script starts by creating a dataset class - [`Text2ImageDataset`](https://github.com/huggingface/diffusers/blob/3b37488fa3280aed6a95de044d7a42ffdcb565ef/examples/consistency_distillation/train_lcm_distill_sd_wds.py#L141) - for preprocessing the images and creating a training dataset.
```py
def transform(... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/lcm_distill.md | https://huggingface.co/docs/diffusers/en/training/lcm_distill/#training-script | #training-script | .md | 35_3 |
Now you're ready to launch the training script and start distilling!
For this guide, you'll use the `--train_shards_path_or_url` to specify the path to the [Conceptual Captions 12M](https://github.com/google-research-datasets/conceptual-12m) dataset stored on the Hub [here](https://huggingface.co/datasets/laion/conce... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/lcm_distill.md | https://huggingface.co/docs/diffusers/en/training/lcm_distill/#launch-the-script | #launch-the-script | .md | 35_4 |
LoRA is a training technique for significantly reducing the number of trainable parameters. As a result, training is faster and it is easier to store the resulting weights because they are a lot smaller (~100MBs). Use the [train_lcm_distill_lora_sd_wds.py](https://github.com/huggingface/diffusers/blob/main/examples/con... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/lcm_distill.md | https://huggingface.co/docs/diffusers/en/training/lcm_distill/#lora | #lora | .md | 35_5 |
Stable Diffusion XL (SDXL) is a powerful text-to-image model that generates high-resolution images, and it adds a second text-encoder to its architecture. Use the [train_lcm_distill_sdxl_wds.py](https://github.com/huggingface/diffusers/blob/main/examples/consistency_distillation/train_lcm_distill_sdxl_wds.py) script to... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/lcm_distill.md | https://huggingface.co/docs/diffusers/en/training/lcm_distill/#stable-diffusion-xl | #stable-diffusion-xl | .md | 35_6 |
Congratulations on distilling a LCM model! To learn more about LCM, the following may be helpful:
- Learn how to use [LCMs for inference](../using-diffusers/lcm) for text-to-image, image-to-image, and with LoRA checkpoints.
- Read the [SDXL in 4 steps with Latent Consistency LoRAs](https://huggingface.co/blog/lcm_lor... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/lcm_distill.md | https://huggingface.co/docs/diffusers/en/training/lcm_distill/#next-steps | #next-steps | .md | 35_7 |
<!--Copyright 2024 Custom Diffusion authors The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/custom_diffusion.md | https://huggingface.co/docs/diffusers/en/training/custom_diffusion/ | .md | 36_0 | |
[Custom Diffusion](https://huggingface.co/papers/2212.04488) is a training technique for personalizing image generation models. Like Textual Inversion, DreamBooth, and LoRA, Custom Diffusion only requires a few (~4-5) example images. This technique works by only training weights in the cross-attention layers, and it us... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/custom_diffusion.md | https://huggingface.co/docs/diffusers/en/training/custom_diffusion/#custom-diffusion | #custom-diffusion | .md | 36_1 |
The training script contains all the parameters to help you customize your training run. These are found in the [`parse_args()`](https://github.com/huggingface/diffusers/blob/64603389da01082055a901f2883c4810d1144edb/examples/custom_diffusion/train_custom_diffusion.py#L319) function. The function comes with default valu... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/custom_diffusion.md | https://huggingface.co/docs/diffusers/en/training/custom_diffusion/#script-parameters | #script-parameters | .md | 36_2 |
Prior preservation loss is a method that uses a model's own generated samples to help it learn how to generate more diverse images. Because these generated sample images belong to the same class as the images you provided, they help the model retain what it has learned about the class and how it can use what it already... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/custom_diffusion.md | https://huggingface.co/docs/diffusers/en/training/custom_diffusion/#prior-preservation-loss | #prior-preservation-loss | .md | 36_3 |
Custom Diffusion includes training the target images with a small set of real images to prevent overfitting. As you can imagine, this can be easy to do when you're only training on a few images! Download 200 real images with `clip_retrieval`. The `class_prompt` should be the same category as the target images. These im... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/custom_diffusion.md | https://huggingface.co/docs/diffusers/en/training/custom_diffusion/#regularization | #regularization | .md | 36_4 |
<Tip>
A lot of the code in the Custom Diffusion training script is similar to the [DreamBooth](dreambooth#training-script) script. This guide instead focuses on the code that is relevant to Custom Diffusion.
</Tip>
The Custom Diffusion training script has two dataset classes:
- [`CustomDiffusionDataset`](https:... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/custom_diffusion.md | https://huggingface.co/docs/diffusers/en/training/custom_diffusion/#training-script | #training-script | .md | 36_5 |
Once you’ve made all your changes or you’re okay with the default configuration, you’re ready to launch the training script! 🚀
In this guide, you'll download and use these example [cat images](https://www.cs.cmu.edu/~custom-diffusion/assets/data.zip). You can also create and use your own dataset if you want (see the... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/custom_diffusion.md | https://huggingface.co/docs/diffusers/en/training/custom_diffusion/#launch-the-script | #launch-the-script | .md | 36_6 |
Congratulations on training a model with Custom Diffusion! 🎉 To learn more:
- Read the [Multi-Concept Customization of Text-to-Image Diffusion](https://www.cs.cmu.edu/~custom-diffusion/) blog post to learn more details about the experimental results from the Custom Diffusion team. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/custom_diffusion.md | https://huggingface.co/docs/diffusers/en/training/custom_diffusion/#next-steps | #next-steps | .md | 36_7 |
Many diffusion systems share the same components, allowing you to adapt a pretrained model for one task to an entirely different task.
This guide will show you how to adapt a pretrained text-to-image model for inpainting by initializing and modifying the architecture of a pretrained [`UNet2DConditionModel`]. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/adapt_a_model.md | https://huggingface.co/docs/diffusers/en/training/adapt_a_model/#adapt-a-model-to-a-new-task | #adapt-a-model-to-a-new-task | .md | 37_0 |
A [`UNet2DConditionModel`] by default accepts 4 channels in the [input sample](https://huggingface.co/docs/diffusers/v0.16.0/en/api/models#diffusers.UNet2DConditionModel.in_channels). For example, load a pretrained text-to-image model like [`stable-diffusion-v1-5/stable-diffusion-v1-5`](https://huggingface.co/stable-di... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/adapt_a_model.md | https://huggingface.co/docs/diffusers/en/training/adapt_a_model/#configure-unet2dconditionmodel-parameters | #configure-unet2dconditionmodel-parameters | .md | 37_1 |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/cogvideox.md | https://huggingface.co/docs/diffusers/en/training/cogvideox/ | .md | 38_0 | |
CogVideoX is a text-to-video generation model focused on creating more coherent videos aligned with a prompt. It achieves this using several methods.
- a 3D variational autoencoder that compresses videos spatially and temporally, improving compression rate and video accuracy.
- an expert transformer block to help a... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/cogvideox.md | https://huggingface.co/docs/diffusers/en/training/cogvideox/#cogvideox | #cogvideox | .md | 38_1 |
The training scripts accepts data in two formats.
The first format is suited for small-scale training, and the second format uses a CSV format, which is more appropriate for streaming data for large-scale training. In the future, Diffusers will support the `<Video>` tag. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/cogvideox.md | https://huggingface.co/docs/diffusers/en/training/cogvideox/#data-preparation | #data-preparation | .md | 38_2 |
Two files where one file contains line-separated prompts and another file contains line-separated paths to video data (the path to video files must be relative to the path you pass when specifying `--instance_data_root`). Let's take a look at an example to understand this better!
Assume you've specified `--instance_d... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/cogvideox.md | https://huggingface.co/docs/diffusers/en/training/cogvideox/#small-format | #small-format | .md | 38_3 |
You could use a single CSV file. For the sake of this example, assume you have a `metadata.csv` file. The expected format is:
```
<CAPTION_COLUMN>,<PATH_TO_VIDEO_COLUMN>
"""A black and white animated sequence featuring a rabbit, named Rabbity Ribfried, and an anthropomorphic goat in a musical, playful environment, sh... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/cogvideox.md | https://huggingface.co/docs/diffusers/en/training/cogvideox/#stream-format | #stream-format | .md | 38_4 |
You need to setup your development environment by installing the necessary requirements. The following packages are required:
- Torch 2.0 or above based on the training features you are utilizing (might require latest or nightly versions for quantized/deepspeed training)
- `pip install diffusers transformers accelerate... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/cogvideox.md | https://huggingface.co/docs/diffusers/en/training/cogvideox/#training | #training | .md | 38_5 |
Once you have trained a lora model, the inference can be done simply loading the lora weights into the `CogVideoXPipeline`.
```python
import torch
from diffusers import CogVideoXPipeline
from diffusers.utils import export_to_video
pipe = CogVideoXPipeline.from_pretrained("THUDM/CogVideoX-2b", torch_dtype=torch.float... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/cogvideox.md | https://huggingface.co/docs/diffusers/en/training/cogvideox/#inference | #inference | .md | 38_6 |
While testing using the diffusers library, all optimizations included in the diffusers library were enabled. This
scheme has not been tested for actual memory usage on devices outside of **NVIDIA A100 / H100** architectures.
Generally, this scheme can be adapted to all **NVIDIA Ampere architecture** and above devices. ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/cogvideox.md | https://huggingface.co/docs/diffusers/en/training/cogvideox/#reduce-memory-usage | #reduce-memory-usage | .md | 38_7 |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/ | .md | 39_0 | |
We ❤️ contributions from the open-source community! Everyone is welcome, and all types of participation –not just code– are valued and appreciated. Answering questions, helping others, reaching out, and improving the documentation are all immensely valuable to the community, so don't be afraid and get involved if you'r... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#how-to-contribute-to-diffusers- | #how-to-contribute-to-diffusers- | .md | 39_1 |
You can contribute in many ways ranging from answering questions on issues and discussions to adding new diffusion models to the core library.
In the following, we give an overview of different ways to contribute, ranked by difficulty in ascending order. All of them are valuable to the community.
* 1. Asking and an... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#overview | #overview | .md | 39_2 |
Any question or comment related to the Diffusers library can be asked on the [discussion forum](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers/) or on [Discord](https://discord.gg/G7tWnz98XR). Such questions and comments include (but are not limited to):
- Reports of training ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#1-asking-and-answering-questions-on-the-diffusers-discussion-forum-or-on-the-diffusers-discord | #1-asking-and-answering-questions-on-the-diffusers-discussion-forum-or-on-the-diffusers-discord | .md | 39_3 |
The 🧨 Diffusers library is robust and reliable thanks to the users who notify us of
the problems they encounter. So thank you for reporting an issue.
Remember, GitHub issues are reserved for technical questions directly related to the Diffusers library, bug reports, feature requests, or feedback on the library desig... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#2-opening-new-issues-on-the-github-issues-tab | #2-opening-new-issues-on-the-github-issues-tab | .md | 39_4 |
A bug report should always have a reproducible code snippet and be as minimal and concise as possible.
This means in more detail:
- Narrow the bug down as much as you can, **do not just dump your whole code file**.
- Format your code.
- Do not include any external libraries except for Diffusers depending on them.
- **A... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#21-reproducible-minimal-bug-reports | #21-reproducible-minimal-bug-reports | .md | 39_5 |
A world-class feature request addresses the following points:
1. Motivation first:
* Is it related to a problem/frustration with the library? If so, please explain
why. Providing a code snippet that demonstrates the problem is best.
* Is it related to something you would need for a project? We'd love to hear
about it... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#22-feature-requests | #22-feature-requests | .md | 39_6 |
Feedback about the library design and why it is good or not good helps the core maintainers immensely to build a user-friendly library. To understand the philosophy behind the current design philosophy, please have a look [here](https://huggingface.co/docs/diffusers/conceptual/philosophy). If you feel like a certain de... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#23-feedback | #23-feedback | .md | 39_7 |
Technical questions are mainly about why certain code of the library was written in a certain way, or what a certain part of the code does. Please make sure to link to the code in question and please provide details on
why this part of the code is difficult to understand.
You can open an issue about a technical quest... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#24-technical-questions | #24-technical-questions | .md | 39_8 |
If the diffusion model community released a new model, pipeline, or scheduler that you would like to see in the Diffusers library, please provide the following information:
* Short description of the diffusion pipeline, model, or scheduler and link to the paper or public release.
* Link to any of its open-source impl... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#25-proposal-to-add-a-new-model-scheduler-or-pipeline | #25-proposal-to-add-a-new-model-scheduler-or-pipeline | .md | 39_9 |
Answering issues on GitHub might require some technical knowledge of Diffusers, but we encourage everybody to give it a try even if you are not 100% certain that your answer is correct.
Some tips to give a high-quality answer to an issue:
- Be as concise and minimal as possible.
- Stay on topic. An answer to the issue ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#3-answering-issues-on-the-github-issues-tab | #3-answering-issues-on-the-github-issues-tab | .md | 39_10 |
*Good first issues* are marked by the [Good first issue](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) label. Usually, the issue already
explains how a potential solution should look so that it is easier to fix.
If the issue hasn't been closed and you would like ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#4-fixing-a-good-first-issue | #4-fixing-a-good-first-issue | .md | 39_11 |
A good library **always** has good documentation! The official documentation is often one of the first points of contact for new users of the library, and therefore contributing to the documentation is a **highly
valuable contribution**.
Contributing to the library can have many forms:
- Correcting spelling or gram... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#5-contribute-to-the-documentation | #5-contribute-to-the-documentation | .md | 39_12 |
> [!TIP]
> Read the [Community pipelines](../using-diffusers/custom_pipeline_overview#community-pipelines) guide to learn more about the difference between a GitHub and Hugging Face Hub community pipeline. If you're interested in why we have community pipelines, take a look at GitHub Issue [#841](https://github.com/hug... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#6-contribute-a-community-pipeline | #6-contribute-a-community-pipeline | .md | 39_13 |
Diffusers examples are a collection of training scripts that reside in [examples](https://github.com/huggingface/diffusers/tree/main/examples).
We support two types of training examples:
- Official training examples
- Research training examples
Research training examples are located in [examples/research_projects... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#7-contribute-to-training-examples | #7-contribute-to-training-examples | .md | 39_14 |
*Good second issues* are marked by the [Good second issue](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+second+issue%22) label. Good second issues are
usually more complicated to solve than [Good first issues](https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aiss... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#8-fixing-a-good-second-issue | #8-fixing-a-good-second-issue | .md | 39_15 |
Pipelines, models, and schedulers are the most important pieces of the Diffusers library.
They provide easy access to state-of-the-art diffusion technologies and thus allow the community to
build powerful generative AI applications.
By adding a new model, pipeline, or scheduler you might enable a new powerful use cas... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#9-adding-pipelines-models-schedulers | #9-adding-pipelines-models-schedulers | .md | 39_16 |
A unique and important feature to understand when adding any pipeline, model or scheduler code is the `# Copied from` mechanism. You'll see this all over the Diffusers codebase, and the reason we use it is to keep the codebase easy to understand and maintain. Marking code with the `# Copied from` mechanism forces the m... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#copied-from-mechanism | #copied-from-mechanism | .md | 39_17 |
**The better your issue is written, the higher the chances that it will be quickly resolved.**
1. Make sure that you've used the correct template for your issue. You can pick between *Bug Report*, *Feature Request*, *Feedback about API Design*, *New model/pipeline/scheduler addition*, *Forum*, or a blank issue. Make ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#how-to-write-a-good-issue | #how-to-write-a-good-issue | .md | 39_18 |
1. Be a chameleon. Understand existing design patterns and syntax and make sure your code additions flow seamlessly into the existing code base. Pull requests that significantly diverge from existing design patterns or user interfaces will not be merged.
2. Be laser focused. A pull request should solve one problem and ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#how-to-write-a-good-pr | #how-to-write-a-good-pr | .md | 39_19 |
Before writing code, we strongly advise you to search through the existing PRs or
issues to make sure that nobody is already working on the same thing. If you are
unsure, it is always a good idea to open an issue to get some feedback.
You will need basic `git` proficiency to be able to contribute to
🧨 Diffusers. `gi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#how-to-open-a-pr | #how-to-open-a-pr | .md | 39_20 |
An extensive test suite is included to test the library behavior and several examples. Library tests can be found in
the [tests folder](https://github.com/huggingface/diffusers/tree/main/tests).
We like `pytest` and `pytest-xdist` because it's faster. From the root of the
repository, here's how to run tests with `pyt... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#tests | #tests | .md | 39_21 |
To avoid pinging the upstream repository which adds reference notes to each upstream PR and sends unnecessary notifications to the developers involved in these PRs,
when syncing the main branch of a forked repository, please, follow these steps:
1. When possible, avoid syncing with the upstream using a branch and PR on... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#syncing-forked-main-with-upstream-huggingface-main | #syncing-forked-main-with-upstream-huggingface-main | .md | 39_22 |
For documentation strings, 🧨 Diffusers follows the [Google style](https://google.github.io/styleguide/pyguide.html). | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/contribution.md | https://huggingface.co/docs/diffusers/en/conceptual/contribution/#style-guide | #style-guide | .md | 39_23 |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/ethical_guidelines.md | https://huggingface.co/docs/diffusers/en/conceptual/ethical_guidelines/ | .md | 40_0 | |
[Diffusers](https://huggingface.co/docs/diffusers/index) provides pre-trained diffusion models and serves as a modular toolbox for inference and training.
Given its real case applications in the world and potential negative impacts on society, we think it is important to provide the project with ethical guidelines to... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/ethical_guidelines.md | https://huggingface.co/docs/diffusers/en/conceptual/ethical_guidelines/#preamble | #preamble | .md | 40_1 |
The Diffusers community will apply the following ethical guidelines to the project’s development and help coordinate how the community will integrate the contributions, especially concerning sensitive topics related to ethical concerns. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/ethical_guidelines.md | https://huggingface.co/docs/diffusers/en/conceptual/ethical_guidelines/#scope | #scope | .md | 40_2 |
The following ethical guidelines apply generally, but we will primarily implement them when dealing with ethically sensitive issues while making a technical choice. Furthermore, we commit to adapting those ethical principles over time following emerging harms related to the state of the art of the technology in questio... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/ethical_guidelines.md | https://huggingface.co/docs/diffusers/en/conceptual/ethical_guidelines/#ethical-guidelines | #ethical-guidelines | .md | 40_3 |
The team works daily to make the technical and non-technical tools available to deal with the potential ethical and social risks associated with diffusion technology. Moreover, the community's input is invaluable in ensuring these features' implementation and raising awareness with us.
- [**Community tab**](https://h... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/ethical_guidelines.md | https://huggingface.co/docs/diffusers/en/conceptual/ethical_guidelines/#examples-of-implementations-safety-features-and-mechanisms | #examples-of-implementations-safety-features-and-mechanisms | .md | 40_4 |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/philosophy.md | https://huggingface.co/docs/diffusers/en/conceptual/philosophy/ | .md | 41_0 | |
🧨 Diffusers provides **state-of-the-art** pretrained diffusion models across multiple modalities.
Its purpose is to serve as a **modular toolbox** for both inference and training.
We aim at building a library that stands the test of time and therefore take API design very seriously.
In a nutshell, Diffusers is bui... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/philosophy.md | https://huggingface.co/docs/diffusers/en/conceptual/philosophy/#philosophy | #philosophy | .md | 41_1 |
- While Diffusers has many built-in performance-enhancing features (see [Memory and Speed](https://huggingface.co/docs/diffusers/optimization/fp16)), models are always loaded with the highest precision and lowest optimization. Therefore, by default diffusion pipelines are always instantiated on CPU with float32 precisi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/philosophy.md | https://huggingface.co/docs/diffusers/en/conceptual/philosophy/#usability-over-performance | #usability-over-performance | .md | 41_2 |
As PyTorch states, **explicit is better than implicit** and **simple is better than complex**. This design philosophy is reflected in multiple parts of the library:
- We follow PyTorch's API with methods like [`DiffusionPipeline.to`](https://huggingface.co/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.Diffusi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/philosophy.md | https://huggingface.co/docs/diffusers/en/conceptual/philosophy/#simple-over-easy | #simple-over-easy | .md | 41_3 |
For large parts of the library, Diffusers adopts an important design principle of the [Transformers library](https://github.com/huggingface/transformers), which is to prefer copy-pasted code over hasty abstractions. This design principle is very opinionated and stands in stark contrast to popular design principles such... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/philosophy.md | https://huggingface.co/docs/diffusers/en/conceptual/philosophy/#tweakable-contributor-friendly-over-abstraction | #tweakable-contributor-friendly-over-abstraction | .md | 41_4 |
Now, let's look a bit into the nitty-gritty details of the design philosophy. Diffusers essentially consists of three major classes: [pipelines](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines), [models](https://github.com/huggingface/diffusers/tree/main/src/diffusers/models), and [schedulers... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/philosophy.md | https://huggingface.co/docs/diffusers/en/conceptual/philosophy/#design-philosophy-in-details | #design-philosophy-in-details | .md | 41_5 |
Pipelines are designed to be easy to use (therefore do not follow [*Simple over easy*](#simple-over-easy) 100%), are not feature complete, and should loosely be seen as examples of how to use [models](#models) and [schedulers](#schedulers) for inference.
The following design principles are followed:
- Pipelines follo... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/philosophy.md | https://huggingface.co/docs/diffusers/en/conceptual/philosophy/#pipelines | #pipelines | .md | 41_6 |
Models are designed as configurable toolboxes that are natural extensions of [PyTorch's Module class](https://pytorch.org/docs/stable/generated/torch.nn.Module.html). They only partly follow the **single-file policy**.
The following design principles are followed:
- Models correspond to **a type of model architecture... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/philosophy.md | https://huggingface.co/docs/diffusers/en/conceptual/philosophy/#models | #models | .md | 41_7 |
Schedulers are responsible to guide the denoising process for inference as well as to define a noise schedule for training. They are designed as individual classes with loadable configuration files and strongly follow the **single-file policy**.
The following design principles are followed:
- All schedulers are found... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/philosophy.md | https://huggingface.co/docs/diffusers/en/conceptual/philosophy/#schedulers | #schedulers | .md | 41_8 |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/evaluation.md | https://huggingface.co/docs/diffusers/en/conceptual/evaluation/ | .md | 42_0 | |
<a target="_blank" href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/evaluation.ipynb">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
Evaluation of generative models like [Stable Diffusion](https://huggingface.co/docs/diffusers/st... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/evaluation.md | https://huggingface.co/docs/diffusers/en/conceptual/evaluation/#evaluating-diffusion-models | #evaluating-diffusion-models | .md | 42_1 |
We cover Diffusion models with the following pipelines:
- Text-guided image generation (such as the [`StableDiffusionPipeline`](https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img)).
- Text-guided image generation, additionally conditioned on an input image (such as the [`StableDiffu... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/evaluation.md | https://huggingface.co/docs/diffusers/en/conceptual/evaluation/#scenarios | #scenarios | .md | 42_2 |
Qualitative evaluation typically involves human assessment of generated images. Quality is measured across aspects such as compositionality, image-text alignment, and spatial relations. Common prompts provide a degree of uniformity for subjective metrics.
DrawBench and PartiPrompts are prompt datasets used for qualitat... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/evaluation.md | https://huggingface.co/docs/diffusers/en/conceptual/evaluation/#qualitative-evaluation | #qualitative-evaluation | .md | 42_3 |
In this section, we will walk you through how to evaluate three different diffusion pipelines using:
- CLIP score
- CLIP directional similarity
- FID | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/evaluation.md | https://huggingface.co/docs/diffusers/en/conceptual/evaluation/#quantitative-evaluation | #quantitative-evaluation | .md | 42_4 |
[CLIP score](https://arxiv.org/abs/2104.08718) measures the compatibility of image-caption pairs. Higher CLIP scores imply higher compatibility 🔼. The CLIP score is a quantitative measurement of the qualitative concept "compatibility". Image-caption pair compatibility can also be thought of as the semantic similarity ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/evaluation.md | https://huggingface.co/docs/diffusers/en/conceptual/evaluation/#text-guided-image-generation | #text-guided-image-generation | .md | 42_5 |
In this case, we condition the generation pipeline with an input image as well as a text prompt. Let's take the [`StableDiffusionInstructPix2PixPipeline`], as an example. It takes an edit instruction as an input prompt and an input image to be edited.
Here is one example:
. Popular metrics for evaluating these models include Fréchet Inception Distance (FID), Kernel Inception Distance (KID), and Inception Score (IS). In this document, we... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/conceptual/evaluation.md | https://huggingface.co/docs/diffusers/en/conceptual/evaluation/#class-conditioned-image-generation | #class-conditioned-image-generation | .md | 42_7 |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/ | .md | 43_0 | |
[bitsandbytes](https://huggingface.co/docs/bitsandbytes/index) is the easiest option for quantizing a model to 8 and 4-bit. 8-bit quantization multiplies outliers in fp16 with non-outliers in int8, converts the non-outlier values back to fp16, and then adds them together to return the weights in fp16. This reduces the ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/#bitsandbytes | #bitsandbytes | .md | 43_1 |
<Tip>
Learn more about the details of 8-bit quantization in this [blog post](https://huggingface.co/blog/hf-bitsandbytes-integration)!
</Tip>
This section explores some of the specific features of 8-bit models, such as outlier thresholds and skipping module conversion. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/#8-bit-llmint8-algorithm | #8-bit-llmint8-algorithm | .md | 43_2 |
An "outlier" is a hidden state value greater than a certain threshold, and these values are computed in fp16. While the values are usually normally distributed ([-3.5, 3.5]), this distribution can be very different for large models ([-60, 6] or [6, 60]). 8-bit quantization works well for values ~5, but beyond that, the... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/#outlier-threshold | #outlier-threshold | .md | 43_3 |
For some models, you don't need to quantize every module to 8-bit which can actually cause instability. For example, for diffusion models like [Stable Diffusion 3](../api/pipelines/stable_diffusion/stable_diffusion_3), the `proj_out` module can be skipped using the `llm_int8_skip_modules` parameter in [`BitsAndBytesCon... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/#skip-module-conversion | #skip-module-conversion | .md | 43_4 |
<Tip>
Learn more about its details in this [blog post](https://huggingface.co/blog/4bit-transformers-bitsandbytes).
</Tip>
This section explores some of the specific features of 4-bit models, such as changing the compute data type, using the Normal Float 4 (NF4) data type, and using nested quantization. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/#4-bit-qlora-algorithm | #4-bit-qlora-algorithm | .md | 43_5 |
To speedup computation, you can change the data type from float32 (the default value) to bf16 using the `bnb_4bit_compute_dtype` parameter in [`BitsAndBytesConfig`]:
```py
import torch
from diffusers import BitsAndBytesConfig
quantization_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.bf... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/#compute-data-type | #compute-data-type | .md | 43_6 |
NF4 is a 4-bit data type from the [QLoRA](https://hf.co/papers/2305.14314) paper, adapted for weights initialized from a normal distribution. You should use NF4 for training 4-bit base models. This can be configured with the `bnb_4bit_quant_type` parameter in the [`BitsAndBytesConfig`]:
```py
from diffusers import Bi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/#normal-float-4-nf4 | #normal-float-4-nf4 | .md | 43_7 |
Nested quantization is a technique that can save additional memory at no additional performance cost. This feature performs a second quantization of the already quantized weights to save an additional 0.4 bits/parameter.
```py
from diffusers import BitsAndBytesConfig as DiffusersBitsAndBytesConfig
from transformers i... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/#nested-quantization | #nested-quantization | .md | 43_8 |
Once quantized, you can dequantize a model to its original precision, but this might result in a small loss of quality. Make sure you have enough GPU RAM to fit the dequantized model.
```python
from diffusers import BitsAndBytesConfig as DiffusersBitsAndBytesConfig
from transformers import BitsAndBytesConfig as Trans... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/#dequantizing-bitsandbytes-models | #dequantizing-bitsandbytes-models | .md | 43_9 |
* [End-to-end notebook showing Flux.1 Dev inference in a free-tier Colab](https://gist.github.com/sayakpaul/c76bd845b48759e11687ac550b99d8b4)
* [Training](https://gist.github.com/sayakpaul/05afd428bc089b47af7c016e42004527) | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/bitsandbytes.md | https://huggingface.co/docs/diffusers/en/quantization/bitsandbytes/#resources | #resources | .md | 43_10 |
<!-- Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or ag... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/torchao.md | https://huggingface.co/docs/diffusers/en/quantization/torchao/ | .md | 44_0 | |
[TorchAO](https://github.com/pytorch/ao) is an architecture optimization library for PyTorch. It provides high-performance dtypes, optimization techniques, and kernels for inference and training, featuring composability with native PyTorch features like [torch.compile](https://pytorch.org/tutorials/intermediate/torch_c... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/torchao.md | https://huggingface.co/docs/diffusers/en/quantization/torchao/#torchao | #torchao | .md | 44_1 |
torchao supports weight-only quantization and weight and dynamic-activation quantization for int8, float3-float8, and uint1-uint7.
Weight-only quantization stores the model weights in a specific low-bit data type but performs computation with a higher-precision data type, like `bfloat16`. This lowers the memory requi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/torchao.md | https://huggingface.co/docs/diffusers/en/quantization/torchao/#supported-quantization-types | #supported-quantization-types | .md | 44_2 |
To serialize a quantized model in a given dtype, first load the model with the desired quantization dtype and then save it using the [`~ModelMixin.save_pretrained`] method.
```python
import torch
from diffusers import FluxTransformer2DModel, TorchAoConfig
quantization_config = TorchAoConfig("int8wo")
transformer = F... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/torchao.md | https://huggingface.co/docs/diffusers/en/quantization/torchao/#serializing-and-deserializing-quantized-models | #serializing-and-deserializing-quantized-models | .md | 44_3 |
- [TorchAO Quantization API](https://github.com/pytorch/ao/blob/main/torchao/quantization/README.md)
- [Diffusers-TorchAO examples](https://github.com/sayakpaul/diffusers-torchao) | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/torchao.md | https://huggingface.co/docs/diffusers/en/quantization/torchao/#resources | #resources | .md | 44_4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.