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 |
|---|---|---|---|---|---|
<!--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/overview.md | https://huggingface.co/docs/diffusers/en/quantization/overview/ | .md | 45_0 | |
Quantization techniques focus on representing data with less information while also trying to not lose too much accuracy. This often means converting a data type to represent the same information with fewer bits. For example, if your model weights are stored as 32-bit floating points and they're quantized to 16-bit flo... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/overview.md | https://huggingface.co/docs/diffusers/en/quantization/overview/#quantization | #quantization | .md | 45_1 |
Diffusers currently supports the following quantization methods.
- [BitsandBytes](./bitsandbytes)
- [TorchAO](./torchao)
- [GGUF](./gguf)
[This resource](https://huggingface.co/docs/transformers/main/en/quantization/overview#when-to-use-what) provides a good overview of the pros and cons of different quantization tec... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/overview.md | https://huggingface.co/docs/diffusers/en/quantization/overview/#when-to-use-what | #when-to-use-what | .md | 45_2 |
<!--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/gguf.md | https://huggingface.co/docs/diffusers/en/quantization/gguf/ | .md | 46_0 | |
The GGUF file format is typically used to store models for inference with [GGML](https://github.com/ggerganov/ggml) and supports a variety of block wise quantization options. Diffusers supports loading checkpoints prequantized and saved in the GGUF format via `from_single_file` loading with Model classes. Loading GGUF ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/gguf.md | https://huggingface.co/docs/diffusers/en/quantization/gguf/#gguf | #gguf | .md | 46_1 |
- BF16
- Q4_0
- Q4_1
- Q5_0
- Q5_1
- Q8_0
- Q2_K
- Q3_K
- Q4_K
- Q5_K
- Q6_K | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/quantization/gguf.md | https://huggingface.co/docs/diffusers/en/quantization/gguf/#supported-quantization-types | #supported-quantization-types | .md | 46_2 |
<!--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/using-diffusers/shap-e.md | https://huggingface.co/docs/diffusers/en/using-diffusers/shap-e/ | .md | 47_0 | |
[[open-in-colab]]
Shap-E is a conditional model for generating 3D assets which could be used for video game development, interior design, and architecture. It is trained on a large dataset of 3D assets, and post-processed to render more views of each object and produce 16K instead of 4K point clouds. The Shap-E model... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/shap-e.md | https://huggingface.co/docs/diffusers/en/using-diffusers/shap-e/#shap-e | #shap-e | .md | 47_1 |
To generate a gif of a 3D object, pass a text prompt to the [`ShapEPipeline`]. The pipeline generates a list of image frames which are used to create the 3D object.
```py
import torch
from diffusers import ShapEPipeline
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
pipe = ShapEPipeline.from_... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/shap-e.md | https://huggingface.co/docs/diffusers/en/using-diffusers/shap-e/#text-to-3d | #text-to-3d | .md | 47_2 |
To generate a 3D object from another image, use the [`ShapEImg2ImgPipeline`]. You can use an existing image or generate an entirely new one. Let's use the [Kandinsky 2.1](../api/pipelines/kandinsky) model to generate a new image.
```py
from diffusers import DiffusionPipeline
import torch
prior_pipeline = DiffusionPi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/shap-e.md | https://huggingface.co/docs/diffusers/en/using-diffusers/shap-e/#image-to-3d | #image-to-3d | .md | 47_3 |
Shap-E is a flexible model that can also generate textured mesh outputs to be rendered for downstream applications. In this example, you'll convert the output into a `glb` file because the 🤗 Datasets library supports mesh visualization of `glb` files which can be rendered by the [Dataset viewer](https://huggingface.co... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/shap-e.md | https://huggingface.co/docs/diffusers/en/using-diffusers/shap-e/#generate-mesh | #generate-mesh | .md | 47_4 |
<!--Copyright 2024 Marigold authors and 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 ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/ | .md | 48_0 | |
[Marigold](../api/pipelines/marigold) is a novel diffusion-based dense prediction approach, and a set of pipelines for various computer vision tasks, such as monocular depth estimation.
This guide will show you how to use Marigold to obtain fast and high-quality predictions for images and videos.
Each pipeline supp... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/#marigold-pipelines-for-computer-vision-tasks | #marigold-pipelines-for-computer-vision-tasks | .md | 48_1 |
To get the first depth prediction, load `prs-eth/marigold-depth-lcm-v1-0` checkpoint into `MarigoldDepthPipeline` pipeline, put the image through the pipeline, and save the predictions:
```python
import diffusers
import torch
pipe = diffusers.MarigoldDepthPipeline.from_pretrained(
"prs-eth/marigold-depth-lcm-v1-0", ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/#depth-prediction-quick-start | #depth-prediction-quick-start | .md | 48_2 |
Load `prs-eth/marigold-normals-lcm-v0-1` checkpoint into `MarigoldNormalsPipeline` pipeline, put the image through the pipeline, and save the predictions:
```python
import diffusers
import torch
pipe = diffusers.MarigoldNormalsPipeline.from_pretrained(
"prs-eth/marigold-normals-lcm-v0-1", variant="fp16", torch_dtype... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/#surface-normals-prediction-quick-start | #surface-normals-prediction-quick-start | .md | 48_3 |
The above quick start snippets are already optimized for speed: they load the LCM checkpoint, use the `fp16` variant of weights and computation, and perform just one denoising diffusion step.
The `pipe(image)` call completes in 280ms on RTX 3090 GPU.
Internally, the input image is encoded with the Stable Diffusion VAE ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/#speeding-up-inference | #speeding-up-inference | .md | 48_4 |
With the above speed optimizations, Marigold delivers predictions with more details and faster than [Depth Anything](https://huggingface.co/docs/transformers/main/en/model_doc/depth_anything) with the largest checkpoint [LiheYoung/depth-anything-large-hf](https://huggingface.co/LiheYoung/depth-anything-large-hf):
<di... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/#qualitative-comparison-with-depth-anything | #qualitative-comparison-with-depth-anything | .md | 48_5 |
Marigold pipelines have a built-in ensembling mechanism combining multiple predictions from different random latents.
This is a brute-force way of improving the precision of predictions, capitalizing on the generative nature of diffusion.
The ensembling path is activated automatically when the `ensemble_size` argument ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/#maximizing-precision-and-ensembling | #maximizing-precision-and-ensembling | .md | 48_6 |
To evaluate Marigold quantitatively in standard leaderboards and benchmarks (such as NYU, KITTI, and other datasets), follow the evaluation protocol outlined in the paper: load the full precision fp32 model and use appropriate values for `num_inference_steps` and `ensemble_size`.
Optionally seed randomness to ensure re... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/#quantitative-evaluation | #quantitative-evaluation | .md | 48_7 |
The ensembling mechanism built into Marigold pipelines combines multiple predictions obtained from different random latents.
As a side effect, it can be used to quantify epistemic (model) uncertainty; simply specify `ensemble_size` greater than 1 and set `output_uncertainty=True`.
The resulting uncertainty will be avai... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/#using-predictive-uncertainty | #using-predictive-uncertainty | .md | 48_8 |
Due to Marigold's generative nature, each prediction is unique and defined by the random noise sampled for the latent initialization.
This becomes an obvious drawback compared to traditional end-to-end dense regression networks, as exemplified in the following videos:
<div class="flex gap-4">
<div style="flex: 1 1 50... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/#frame-by-frame-video-processing-with-temporal-consistency | #frame-by-frame-video-processing-with-temporal-consistency | .md | 48_9 |
A very common application for depth prediction with diffusion models comes in conjunction with ControlNet.
Depth crispness plays a crucial role in obtaining high-quality results from ControlNet.
As seen in comparisons with other methods above, Marigold excels at that task.
The snippet below demonstrates how to load an ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/marigold_usage.md | https://huggingface.co/docs/diffusers/en/using-diffusers/marigold_usage/#marigold-for-controlnet | #marigold-for-controlnet | .md | 48_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 agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/textual_inversion_inference.md | https://huggingface.co/docs/diffusers/en/using-diffusers/textual_inversion_inference/ | .md | 49_0 | |
[[open-in-colab]]
The [`StableDiffusionPipeline`] supports textual inversion, a technique that enables a model like Stable Diffusion to learn a new concept from just a few sample images. This gives you more control over the generated images and allows you to tailor the model towards specific concepts. You can get sta... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/textual_inversion_inference.md | https://huggingface.co/docs/diffusers/en/using-diffusers/textual_inversion_inference/#textual-inversion | #textual-inversion | .md | 49_1 |
Pick a Stable Diffusion checkpoint and a pre-learned concept from the [Stable Diffusion Conceptualizer](https://huggingface.co/spaces/sd-concepts-library/stable-diffusion-conceptualizer):
```py
pretrained_model_name_or_path = "stable-diffusion-v1-5/stable-diffusion-v1-5"
repo_id_embeds = "sd-concepts-library/cat-toy"... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/textual_inversion_inference.md | https://huggingface.co/docs/diffusers/en/using-diffusers/textual_inversion_inference/#stable-diffusion-1-and-2 | #stable-diffusion-1-and-2 | .md | 49_2 |
Stable Diffusion XL (SDXL) can also use textual inversion vectors for inference. In contrast to Stable Diffusion 1 and 2, SDXL has two text encoders so you'll need two textual inversion embeddings - one for each text encoder model.
Let's download the SDXL textual inversion embeddings and have a closer look at it's st... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/textual_inversion_inference.md | https://huggingface.co/docs/diffusers/en/using-diffusers/textual_inversion_inference/#stable-diffusion-xl | #stable-diffusion-xl | .md | 49_3 |
<!--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/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/ | .md | 50_0 | |
[IP-Adapter](https://hf.co/papers/2308.06721) is an image prompt adapter that can be plugged into diffusion models to enable image prompting without any changes to the underlying model. Furthermore, this adapter can be reused with other models finetuned from the same base model and it can be combined with other adapter... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#ip-adapter | #ip-adapter | .md | 50_1 |
Let's take a look at how to use IP-Adapter's image prompting capabilities with the [`StableDiffusionXLPipeline`] for tasks like text-to-image, image-to-image, and inpainting. We also encourage you to try out other pipelines such as Stable Diffusion, LCM-LoRA, ControlNet, T2I-Adapter, or AnimateDiff!
In all the follow... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#general-tasks | #general-tasks | .md | 50_2 |
There are a couple of IP-Adapter parameters that are useful to know about and can help you with your image generation tasks. These parameters can make your workflow more efficient or give you more control over image generation. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#configure-parameters | #configure-parameters | .md | 50_3 |
IP-Adapter enabled pipelines provide the `ip_adapter_image_embeds` parameter to accept precomputed image embeddings. This is particularly useful in scenarios where you need to run the IP-Adapter pipeline multiple times because you have more than one image. For example, [multi IP-Adapter](#multi-ip-adapter) is a specifi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#image-embeddings | #image-embeddings | .md | 50_4 |
Binary masks specify which portion of the output image should be assigned to an IP-Adapter. This is useful for composing more than one IP-Adapter image. For each input IP-Adapter image, you must provide a binary mask.
To start, preprocess the input IP-Adapter images with the [`~image_processor.IPAdapterMaskProcessor.... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#ip-adapter-masking | #ip-adapter-masking | .md | 50_5 |
IP-Adapter's image prompting and compatibility with other adapters and models makes it a versatile tool for a variety of use cases. This section covers some of the more popular applications of IP-Adapter, and we can't wait to see what you come up with! | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#specific-use-cases | #specific-use-cases | .md | 50_6 |
Generating accurate faces is challenging because they are complex and nuanced. Diffusers supports two IP-Adapter checkpoints specifically trained to generate faces from the [h94/IP-Adapter](https://huggingface.co/h94/IP-Adapter) repository:
* [ip-adapter-full-face_sd15.safetensors](https://huggingface.co/h94/IP-Adapt... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#face-model | #face-model | .md | 50_7 |
More than one IP-Adapter can be used at the same time to generate specific images in more diverse styles. For example, you can use IP-Adapter-Face to generate consistent faces and characters, and IP-Adapter Plus to generate those faces in a specific style.
> [!TIP]
> Read the [IP-Adapter Plus](../using-diffusers/load... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#multi-ip-adapter | #multi-ip-adapter | .md | 50_8 |
[Latent Consistency Models (LCM)](../using-diffusers/inference_with_lcm_lora) are diffusion models that can generate images in as little as 4 steps compared to other diffusion models like SDXL that typically require way more steps. This is why image generation with an LCM feels "instantaneous". IP-Adapters can be plugg... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#instant-generation | #instant-generation | .md | 50_9 |
To control image generation to an even greater degree, you can combine IP-Adapter with a model like [ControlNet](../using-diffusers/controlnet). A ControlNet is also an adapter that can be inserted into a diffusion model to allow for conditioning on an additional control image. The control image can be depth maps, edge... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#structural-control | #structural-control | .md | 50_10 |
[InstantStyle](https://arxiv.org/abs/2404.02733) is a plug-and-play method on top of IP-Adapter, which disentangles style and layout from image prompt to control image generation. This way, you can generate images following only the style or layout from image prompt, with significantly improved diversity. This is achie... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/ip_adapter.md | https://huggingface.co/docs/diffusers/en/using-diffusers/ip_adapter/#style--layout-control | #style--layout-control | .md | 50_11 |
<!--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/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/ | .md | 51_0 | |
[[open-in-colab]]
Prompts are important because they describe what you want a diffusion model to generate. The best prompts are detailed, specific, and well-structured to help the model realize your vision. But crafting a great prompt takes time and effort and sometimes it may not be enough because language and words... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/#prompt-techniques | #prompt-techniques | .md | 51_1 |
> [!TIP]
> This is not an exhaustive guide on prompt engineering, but it will help you understand the necessary parts of a good prompt. We encourage you to continue experimenting with different prompts and combine them in new ways to see what works best. As you write more prompts, you'll develop an intuition for what w... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/#prompt-engineering | #prompt-engineering | .md | 51_2 |
Prompt enhancing is a technique for quickly improving prompt quality without spending too much effort constructing one. It uses a model like GPT2 pretrained on Stable Diffusion text prompts to automatically enrich a prompt with additional important keywords to generate high-quality images.
The technique works by cura... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/#prompt-enhancing-with-gpt2 | #prompt-enhancing-with-gpt2 | .md | 51_3 |
Prompt weighting provides a way to emphasize or de-emphasize certain parts of a prompt, allowing for more control over the generated image. A prompt can include several concepts, which gets turned into contextualized text embeddings. The embeddings are used by the model to condition its cross-attention layers to genera... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/#prompt-weighting | #prompt-weighting | .md | 51_4 |
You'll notice there is no "ball" in the image! Let's use compel to upweight the concept of "ball" in the prompt. Create a [`Compel`](https://github.com/damian0815/compel/blob/main/doc/compel.md#compel-objects) object, and pass it a tokenizer and text encoder:
```py
from compel import Compel
compel_proc = Compel(toke... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/#weighting | #weighting | .md | 51_5 |
You can also create a weighted *blend* of prompts by adding `.blend()` to a list of prompts and passing it some weights. Your blend may not always produce the result you expect because it breaks some assumptions about how the text encoder functions, so just have fun and experiment with it!
```py
prompt_embeds = compe... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/#blending | #blending | .md | 51_6 |
A conjunction diffuses each prompt independently and concatenates their results by their weighted sum. Add `.and()` to the end of a list of prompts to create a conjunction:
```py
prompt_embeds = compel_proc('["a red cat", "playing with a", "ball"].and()')
generator = torch.Generator(device="cuda").manual_seed(55)
im... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/#conjunction | #conjunction | .md | 51_7 |
[Textual inversion](../training/text_inversion) is a technique for learning a specific concept from some images which you can use to generate new images conditioned on that concept.
Create a pipeline and use the [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] function to load the textual inversion emb... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/#textual-inversion | #textual-inversion | .md | 51_8 |
[DreamBooth](../training/dreambooth) is a technique for generating contextualized images of a subject given just a few images of the subject to train on. It is similar to textual inversion, but DreamBooth trains the full model whereas textual inversion only fine-tunes the text embeddings. This means you should use [`~D... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/#dreambooth | #dreambooth | .md | 51_9 |
Stable Diffusion XL (SDXL) has two tokenizers and text encoders so it's usage is a bit different. To address this, you should pass both tokenizers and encoders to the `Compel` class:
```py
from compel import Compel, ReturnedEmbeddingsType
from diffusers import DiffusionPipeline
from diffusers.utils import make_image_... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/weighted_prompts.md | https://huggingface.co/docs/diffusers/en/using-diffusers/weighted_prompts/#stable-diffusion-xl | #stable-diffusion-xl | .md | 51_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 agr... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/loading_adapters.md | https://huggingface.co/docs/diffusers/en/using-diffusers/loading_adapters/ | .md | 52_0 | |
[[open-in-colab]]
There are several [training](../training/overview) techniques for personalizing diffusion models to generate images of a specific subject or images in certain styles. Each of these training methods produces a different type of adapter. Some of the adapters generate an entirely new model, while other... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/loading_adapters.md | https://huggingface.co/docs/diffusers/en/using-diffusers/loading_adapters/#load-adapters | #load-adapters | .md | 52_1 |
[DreamBooth](https://dreambooth.github.io/) finetunes an *entire diffusion model* on just several images of a subject to generate images of that subject in new styles and settings. This method works by using a special word in the prompt that the model learns to associate with the subject image. Of all the training meth... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/loading_adapters.md | https://huggingface.co/docs/diffusers/en/using-diffusers/loading_adapters/#dreambooth | #dreambooth | .md | 52_2 |
[Textual inversion](https://textual-inversion.github.io/) is very similar to DreamBooth and it can also personalize a diffusion model to generate certain concepts (styles, objects) from just a few images. This method works by training and finding new embeddings that represent the images you provide with a special word ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/loading_adapters.md | https://huggingface.co/docs/diffusers/en/using-diffusers/loading_adapters/#textual-inversion | #textual-inversion | .md | 52_3 |
[Low-Rank Adaptation (LoRA)](https://huggingface.co/papers/2106.09685) is a popular training technique because it is fast and generates smaller file sizes (a couple hundred MBs). Like the other methods in this guide, LoRA can train a model to learn new styles from just a few images. It works by inserting new weights in... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/loading_adapters.md | https://huggingface.co/docs/diffusers/en/using-diffusers/loading_adapters/#lora | #lora | .md | 52_4 |
For both [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] and [`~loaders.UNet2DConditionLoadersMixin.load_attn_procs`], you can pass the `cross_attention_kwargs={"scale": 0.5}` parameter to adjust how much of the LoRA weights to use. A value of `0` is the same as only using the base model weights, and a va... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/loading_adapters.md | https://huggingface.co/docs/diffusers/en/using-diffusers/loading_adapters/#adjust-lora-weight-scale | #adjust-lora-weight-scale | .md | 52_5 |
Other popular LoRA trainers from the community include those by [Kohya](https://github.com/kohya-ss/sd-scripts/) and [TheLastBen](https://github.com/TheLastBen/fast-stable-diffusion). These trainers create different LoRA checkpoints than those trained by 🤗 Diffusers, but they can still be loaded in the same way.
<hf... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/loading_adapters.md | https://huggingface.co/docs/diffusers/en/using-diffusers/loading_adapters/#kohya-and-thelastben | #kohya-and-thelastben | .md | 52_6 |
[IP-Adapter](https://ip-adapter.github.io/) is a lightweight adapter that enables image prompting for any diffusion model. This adapter works by decoupling the cross-attention layers of the image and text features. All the other model components are frozen and only the embedded image features in the UNet are trained. A... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/loading_adapters.md | https://huggingface.co/docs/diffusers/en/using-diffusers/loading_adapters/#ip-adapter | #ip-adapter | .md | 52_7 |
IP-Adapter relies on an image encoder to generate image features. If the IP-Adapter repository contains an `image_encoder` subfolder, the image encoder is automatically loaded and registered to the pipeline. Otherwise, you'll need to explicitly load the image encoder with a [`~transformers.CLIPVisionModelWithProjection... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/loading_adapters.md | https://huggingface.co/docs/diffusers/en/using-diffusers/loading_adapters/#ip-adapter-plus | #ip-adapter-plus | .md | 52_8 |
The IP-Adapter FaceID models are experimental IP Adapters that use image embeddings generated by `insightface` instead of CLIP image embeddings. Some of these models also use LoRA to improve ID consistency.
You need to install `insightface` and all its requirements to use these models.
<Tip warning={true}>
As Insight... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/loading_adapters.md | https://huggingface.co/docs/diffusers/en/using-diffusers/loading_adapters/#ip-adapter-face-id-models | #ip-adapter-face-id-models | .md | 52_9 |
<!--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/using-diffusers/inference_with_tcd_lora.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_tcd_lora/ | .md | 53_0 | |
Trajectory Consistency Distillation (TCD) enables a model to generate higher quality and more detailed images with fewer steps. Moreover, owing to the effective error mitigation during the distillation process, TCD demonstrates superior performance even under conditions of large inference steps.
The major advantages ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_tcd_lora.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_tcd_lora/#trajectory-consistency-distillation-lora | #trajectory-consistency-distillation-lora | .md | 53_1 |
In this guide, let's use the [`StableDiffusionXLPipeline`] and the [`TCDScheduler`]. Use the [`~StableDiffusionPipeline.load_lora_weights`] method to load the SDXL-compatible TCD-LoRA weights.
A few tips to keep in mind for TCD-LoRA inference are to:
- Keep the `num_inference_steps` between 4 and 50
- Set `eta` (us... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_tcd_lora.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_tcd_lora/#general-tasks | #general-tasks | .md | 53_2 |
TCD-LoRA also works with many community finetuned models and plugins. For example, load the [animagine-xl-3.0](https://huggingface.co/cagliostrolab/animagine-xl-3.0) checkpoint which is a community finetuned version of SDXL for generating anime images.
```python
import torch
from diffusers import StableDiffusionXLPip... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_tcd_lora.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_tcd_lora/#community-models | #community-models | .md | 53_3 |
TCD-LoRA is very versatile, and it can be combined with other adapter types like ControlNets, IP-Adapter, and AnimateDiff.
<hfoptions id="adapters">
<hfoption id="ControlNet"> | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_tcd_lora.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_tcd_lora/#adapters | #adapters | .md | 53_4 |
```python
import torch
import numpy as np
from PIL import Image
from transformers import DPTImageProcessor, DPTForDepthEstimation
from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline
from diffusers.utils import load_image, make_image_grid
from scheduling_tcd import TCDScheduler
device = "cuda"
de... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_tcd_lora.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_tcd_lora/#depth-controlnet | #depth-controlnet | .md | 53_5 |
```python
import torch
from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline
from diffusers.utils import load_image, make_image_grid
from scheduling_tcd import TCDScheduler
device = "cuda"
base_model_id = "stabilityai/stable-diffusion-xl-base-1.0"
controlnet_id = "diffusers/controlnet-canny-sdxl-1... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_tcd_lora.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_tcd_lora/#canny-controlnet | #canny-controlnet | .md | 53_6 |
<!--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/using-diffusers/kandinsky.md | https://huggingface.co/docs/diffusers/en/using-diffusers/kandinsky/ | .md | 54_0 | |
[[open-in-colab]]
The Kandinsky models are a series of multilingual text-to-image generation models. The Kandinsky 2.0 model uses two multilingual text encoders and concatenates those results for the UNet.
[Kandinsky 2.1](../api/pipelines/kandinsky) changes the architecture to include an image prior model ([`CLIP`]... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/kandinsky.md | https://huggingface.co/docs/diffusers/en/using-diffusers/kandinsky/#kandinsky | #kandinsky | .md | 54_1 |
To use the Kandinsky models for any task, you always start by setting up the prior pipeline to encode the prompt and generate the image embeddings. The prior pipeline also generates `negative_image_embeds` that correspond to the negative prompt `""`. For better results, you can pass an actual `negative_prompt` to the p... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/kandinsky.md | https://huggingface.co/docs/diffusers/en/using-diffusers/kandinsky/#text-to-image | #text-to-image | .md | 54_2 |
For image-to-image, pass the initial image and text prompt to condition the image to the pipeline. Start by loading the prior pipeline:
<hfoptions id="image-to-image">
<hfoption id="Kandinsky 2.1">
```py
import torch
from diffusers import KandinskyImg2ImgPipeline, KandinskyPriorPipeline
prior_pipeline = KandinskyP... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/kandinsky.md | https://huggingface.co/docs/diffusers/en/using-diffusers/kandinsky/#image-to-image | #image-to-image | .md | 54_3 |
<Tip warning={true}>
⚠️ The Kandinsky models use ⬜️ **white pixels** to represent the masked area now instead of black pixels. If you are using [`KandinskyInpaintPipeline`] in production, you need to change the mask to use white pixels:
```py
# For PIL input
import PIL.ImageOps
mask = PIL.ImageOps.invert(mask)
# F... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/kandinsky.md | https://huggingface.co/docs/diffusers/en/using-diffusers/kandinsky/#inpainting | #inpainting | .md | 54_4 |
Interpolation allows you to explore the latent space between the image and text embeddings which is a cool way to see some of the prior model's intermediate outputs. Load the prior pipeline and two images you'd like to interpolate:
<hfoptions id="interpolate">
<hfoption id="Kandinsky 2.1">
```py
from diffusers impo... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/kandinsky.md | https://huggingface.co/docs/diffusers/en/using-diffusers/kandinsky/#interpolation | #interpolation | .md | 54_5 |
<Tip warning={true}>
⚠️ ControlNet is only supported for Kandinsky 2.2!
</Tip>
ControlNet enables conditioning large pretrained diffusion models with additional inputs such as a depth map or edge detection. For example, you can condition Kandinsky 2.2 with a depth map so the model understands and preserves the st... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/kandinsky.md | https://huggingface.co/docs/diffusers/en/using-diffusers/kandinsky/#controlnet | #controlnet | .md | 54_6 |
Load the prior pipeline and the [`KandinskyV22ControlnetPipeline`]:
```py
from diffusers import KandinskyV22PriorPipeline, KandinskyV22ControlnetPipeline
prior_pipeline = KandinskyV22PriorPipeline.from_pretrained(
"kandinsky-community/kandinsky-2-2-prior", torch_dtype=torch.float16, use_safetensors=True
).to("cuda")... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/kandinsky.md | https://huggingface.co/docs/diffusers/en/using-diffusers/kandinsky/#text-to-image-controlnet-text-to-image | #text-to-image-controlnet-text-to-image | .md | 54_7 |
For image-to-image with ControlNet, you'll need to use the:
- [`KandinskyV22PriorEmb2EmbPipeline`] to generate the image embeddings from a text prompt and an image
- [`KandinskyV22ControlnetImg2ImgPipeline`] to generate an image from the initial image and the image embeddings
Process and extract a depth map of an i... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/kandinsky.md | https://huggingface.co/docs/diffusers/en/using-diffusers/kandinsky/#image-to-image-controlnet-image-to-image | #image-to-image-controlnet-image-to-image | .md | 54_8 |
Kandinsky is unique because it requires a prior pipeline to generate the mappings, and a second pipeline to decode the latents into an image. Optimization efforts should be focused on the second pipeline because that is where the bulk of the computation is done. Here are some tips to improve Kandinsky during inference.... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/kandinsky.md | https://huggingface.co/docs/diffusers/en/using-diffusers/kandinsky/#optimizations | #optimizations | .md | 54_9 |
<!--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/using-diffusers/scheduler_features.md | https://huggingface.co/docs/diffusers/en/using-diffusers/scheduler_features/ | .md | 55_0 | |
The scheduler is an important component of any diffusion model because it controls the entire denoising (or sampling) process. There are many types of schedulers, some are optimized for speed and some for quality. With Diffusers, you can modify the scheduler configuration to use custom noise schedules, sigmas, and resc... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/scheduler_features.md | https://huggingface.co/docs/diffusers/en/using-diffusers/scheduler_features/#scheduler-features | #scheduler-features | .md | 55_1 |
The timestep or noise schedule determines the amount of noise at each sampling step. The scheduler uses this to generate an image with the corresponding amount of noise at each step. The timestep schedule is generated from the scheduler's default configuration, but you can customize the scheduler to use new and optimiz... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/scheduler_features.md | https://huggingface.co/docs/diffusers/en/using-diffusers/scheduler_features/#timestep-schedules | #timestep-schedules | .md | 55_2 |
The way sample steps are selected in the schedule can affect the quality of the generated image, especially with respect to [rescaling the noise schedule](#rescale-noise-schedule), which can enable a model to generate much brighter or darker images. Diffusers provides three timestep spacing methods:
- `leading` creat... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/scheduler_features.md | https://huggingface.co/docs/diffusers/en/using-diffusers/scheduler_features/#timestep-spacing | #timestep-spacing | .md | 55_3 |
The `sigmas` parameter is the amount of noise added at each timestep according to the timestep schedule. Like the `timesteps` parameter, you can customize the `sigmas` parameter to control how much noise is added at each step. When you use a custom `sigmas` value, the `timesteps` are calculated from the custom `sigmas`... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/scheduler_features.md | https://huggingface.co/docs/diffusers/en/using-diffusers/scheduler_features/#sigmas | #sigmas | .md | 55_4 |
> [!TIP]
> Refer to the scheduler API [overview](../api/schedulers/overview) for a list of schedulers that support Karras sigmas.
>
> Karras sigmas should not be used for models that weren't trained with them. For example, the base Stable Diffusion XL model shouldn't use Karras sigmas but the [DreamShaperXL](https://hf... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/scheduler_features.md | https://huggingface.co/docs/diffusers/en/using-diffusers/scheduler_features/#karras-sigmas | #karras-sigmas | .md | 55_5 |
In the [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://hf.co/papers/2305.08891) paper, the authors discovered that common noise schedules allowed some signal to leak into the last timestep. This signal leakage at inference can cause models to only generate images with medium brightness. By enforc... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/scheduler_features.md | https://huggingface.co/docs/diffusers/en/using-diffusers/scheduler_features/#rescale-noise-schedule | #rescale-noise-schedule | .md | 55_6 |
<!--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/using-diffusers/reusing_seeds.md | https://huggingface.co/docs/diffusers/en/using-diffusers/reusing_seeds/ | .md | 56_0 | |
Diffusion models are inherently random which is what allows it to generate different outputs every time it is run. But there are certain times when you want to generate the same output every time, like when you're testing, replicating results, and even [improving image quality](#deterministic-batch-generation). While y... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/reusing_seeds.md | https://huggingface.co/docs/diffusers/en/using-diffusers/reusing_seeds/#reproducible-pipelines | #reproducible-pipelines | .md | 56_1 |
During inference, pipelines rely heavily on random sampling operations which include creating the
Gaussian noise tensors to denoise and adding noise to the scheduling step.
Take a look at the tensor values in the [`DDIMPipeline`] after two inference steps.
```python
from diffusers import DDIMPipeline
import numpy a... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/reusing_seeds.md | https://huggingface.co/docs/diffusers/en/using-diffusers/reusing_seeds/#control-randomness | #control-randomness | .md | 56_2 |
You can also configure PyTorch to use deterministic algorithms to create a reproducible pipeline. The downside is that deterministic algorithms may be slower than non-deterministic ones and you may observe a decrease in performance.
Non-deterministic behavior occurs when operations are launched in more than one CUDA ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/reusing_seeds.md | https://huggingface.co/docs/diffusers/en/using-diffusers/reusing_seeds/#deterministic-algorithms | #deterministic-algorithms | .md | 56_3 |
A practical application of creating reproducible pipelines is *deterministic batch generation*. You generate a batch of images and select one image to improve with a more detailed prompt. The main idea is to pass a list of [Generator's](https://pytorch.org/docs/stable/generated/torch.Generator.html) to the pipeline and... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/reusing_seeds.md | https://huggingface.co/docs/diffusers/en/using-diffusers/reusing_seeds/#deterministic-batch-generation | #deterministic-batch-generation | .md | 56_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/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/ | .md | 57_0 | |
[[open-in-colab]]
When you think of diffusion models, text-to-image is usually one of the first things that come to mind. Text-to-image generates an image from a text description (for example, "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k") which is also known as a *prompt*.
From a very hig... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#text-to-image | #text-to-image | .md | 57_1 |
The most common text-to-image models are [Stable Diffusion v1.5](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5), [Stable Diffusion XL (SDXL)](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0), and [Kandinsky 2.2](https://huggingface.co/kandinsky-community/kandinsky-2-2-decoder). Ther... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#popular-models | #popular-models | .md | 57_2 |
[Stable Diffusion v1.5](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5) is a latent diffusion model initialized from [Stable Diffusion v1-4](https://huggingface.co/CompVis/stable-diffusion-v1-4), and finetuned for 595K steps on 512x512 images from the LAION-Aesthetics V2 dataset. You can use this mo... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#stable-diffusion-v15 | #stable-diffusion-v15 | .md | 57_3 |
SDXL is a much larger version of the previous Stable Diffusion models, and involves a two-stage model process that adds even more details to an image. It also includes some additional *micro-conditionings* to generate high-quality images centered subjects. Take a look at the more comprehensive [SDXL](sdxl) guide to lea... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#stable-diffusion-xl | #stable-diffusion-xl | .md | 57_4 |
The Kandinsky model is a bit different from the Stable Diffusion models because it also uses an image prior model to create embeddings that are used to better align text and images in the diffusion model.
The easiest way to use Kandinsky 2.2 is:
```py
from diffusers import AutoPipelineForText2Image
import torch
pi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#kandinsky-22 | #kandinsky-22 | .md | 57_5 |
ControlNet models are auxiliary models or adapters that are finetuned on top of text-to-image models, such as [Stable Diffusion v1.5](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5). Using ControlNet models in combination with text-to-image models offers diverse options for more explicit control ove... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#controlnet | #controlnet | .md | 57_6 |
There are a number of parameters that can be configured in the pipeline that affect how an image is generated. You can change the image's output size, specify a negative prompt to improve image quality, and more. This section dives deeper into how to use these parameters. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#configure-pipeline-parameters | #configure-pipeline-parameters | .md | 57_7 |
The `height` and `width` parameters control the height and width (in pixels) of the generated image. By default, the Stable Diffusion v1.5 model outputs 512x512 images, but you can change this to any size that is a multiple of 8. For example, to create a rectangular image:
```py
from diffusers import AutoPipelineForT... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#height-and-width | #height-and-width | .md | 57_8 |
The `guidance_scale` parameter affects how much the prompt influences image generation. A lower value gives the model "creativity" to generate images that are more loosely related to the prompt. Higher `guidance_scale` values push the model to follow the prompt more closely, and if this value is too high, you may obser... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#guidance-scale | #guidance-scale | .md | 57_9 |
Just like how a prompt guides generation, a *negative prompt* steers the model away from things you don't want the model to generate. This is commonly used to improve overall image quality by removing poor or bad image features such as "low resolution" or "bad details". You can also use a negative prompt to remove or m... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#negative-prompt | #negative-prompt | .md | 57_10 |
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html#generator) object enables reproducibility in a pipeline by setting a manual seed. You can use a `Generator` to generate batches of images and iteratively improve on an image generated from a seed as detailed in the [Improve image quali... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/conditional_image_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/conditional_image_generation/#generator | #generator | .md | 57_11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.