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 |
|---|---|---|---|---|---|
There are several ways to exert more control over how an image is generated outside of configuring a pipeline's parameters, such as prompt weighting and ControlNet models. | /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/#control-image-generation | #control-image-generation | .md | 57_12 |
Prompt weighting is a technique for increasing or decreasing the importance of concepts in a prompt to emphasize or minimize certain features in an image. We recommend using the [Compel](https://github.com/damian0815/compel) library to help you generate the weighted prompt embeddings.
<Tip>
Learn how to create the ... | /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/#prompt-weighting | #prompt-weighting | .md | 57_13 |
As you saw in the [ControlNet](#controlnet) section, these models offer a more flexible and accurate way to generate images by incorporating an additional conditioning image input. Each ControlNet model is pretrained on a particular type of conditioning image to generate new images that resemble it. For example, if you... | /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_14 |
Diffusion models are large, and the iterative nature of denoising an image is computationally expensive and intensive. But this doesn't mean you need access to powerful - or even many - GPUs to use them. There are many optimization techniques for running diffusion models on consumer and free-tier resources. For example... | /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/#optimize | #optimize | .md | 57_15 |
<!--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/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/ | .md | 58_0 | |
[[open-in-colab]]
[Stable Diffusion XL](https://huggingface.co/papers/2307.01952) (SDXL) is a powerful text-to-image generation model that iterates on the previous Stable Diffusion models in three key ways:
1. the UNet is 3x larger and SDXL combines a second text encoder (OpenCLIP ViT-bigG/14) with the original tex... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#stable-diffusion-xl | #stable-diffusion-xl | .md | 58_1 |
Model weights may be stored in separate subfolders on the Hub or locally, in which case, you should use the [`~StableDiffusionXLPipeline.from_pretrained`] method:
```py
from diffusers import StableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline
import torch
pipeline = StableDiffusionXLPipeline.from_pretrained(... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#load-model-checkpoints | #load-model-checkpoints | .md | 58_2 |
For text-to-image, pass a text prompt. By default, SDXL generates a 1024x1024 image for the best results. You can try setting the `height` and `width` parameters to 768x768 or 512x512, but anything below 512x512 is not likely to work.
```py
from diffusers import AutoPipelineForText2Image
import torch
pipeline_text2i... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#text-to-image | #text-to-image | .md | 58_3 |
For image-to-image, SDXL works especially well with image sizes between 768x768 and 1024x1024. Pass an initial image, and a text prompt to condition the image with:
```py
from diffusers import AutoPipelineForImage2Image
from diffusers.utils import load_image, make_image_grid
# use from_pipe to avoid consuming additi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#image-to-image | #image-to-image | .md | 58_4 |
For inpainting, you'll need the original image and a mask of what you want to replace in the original image. Create a prompt to describe what you want to replace the masked area with.
```py
from diffusers import AutoPipelineForInpainting
from diffusers.utils import load_image, make_image_grid
# use from_pipe to avoi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#inpainting | #inpainting | .md | 58_5 |
SDXL includes a [refiner model](https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0) specialized in denoising low-noise stage images to generate higher-quality images from the base model. There are two ways to use the refiner:
1. use the base and refiner models together to produce a refined image
2. us... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#refine-image-quality | #refine-image-quality | .md | 58_6 |
When you use the base and refiner model together to generate an image, this is known as an [*ensemble of expert denoisers*](https://research.nvidia.com/labs/dir/eDiff-I/). The ensemble of expert denoisers approach requires fewer overall denoising steps versus passing the base model's output to the refiner model, so it ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#base--refiner-model | #base--refiner-model | .md | 58_7 |
SDXL gets a boost in image quality by using the refiner model to add additional high-quality details to the fully-denoised image from the base model, in an image-to-image setting.
Load the base and refiner models:
```py
from diffusers import DiffusionPipeline
import torch
base = DiffusionPipeline.from_pretrained(
... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#base-to-refiner-model | #base-to-refiner-model | .md | 58_8 |
SDXL training involves several additional conditioning techniques, which are referred to as *micro-conditioning*. These include original image size, target image size, and cropping parameters. The micro-conditionings can be used at inference time to create high-quality, centered images.
<Tip>
You can use both micro... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#micro-conditioning | #micro-conditioning | .md | 58_9 |
There are two types of size conditioning:
- [`original_size`](https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/stable_diffusion_xl#diffusers.StableDiffusionXLPipeline.__call__.original_size) conditioning comes from upscaled images in the training batch (because it would be wasteful to disc... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#size-conditioning | #size-conditioning | .md | 58_10 |
Images generated by previous Stable Diffusion models may sometimes appear to be cropped. This is because images are actually cropped during training so that all the images in a batch have the same size. By conditioning on crop coordinates, SDXL *learns* that no cropping - coordinates `(0, 0)` - usually correlates with ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#crop-conditioning | #crop-conditioning | .md | 58_11 |
SDXL uses two text-encoders, so it is possible to pass a different prompt to each text-encoder, which can [improve quality](https://github.com/huggingface/diffusers/issues/4004#issuecomment-1627764201). Pass your original prompt to `prompt` and the second prompt to `prompt_2` (use `negative_prompt` and `negative_prompt... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#use-a-different-prompt-for-each-text-encoder | #use-a-different-prompt-for-each-text-encoder | .md | 58_12 |
SDXL is a large model, and you may need to optimize memory to get it to run on your hardware. Here are some tips to save memory and speed up inference.
1. Offload the model to the CPU with [`~StableDiffusionXLPipeline.enable_model_cpu_offload`] for out-of-memory errors:
```diff
- base.to("cuda")
- refiner.to("cuda"... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#optimizations | #optimizations | .md | 58_13 |
If you're interested in experimenting with a minimal version of the [`UNet2DConditionModel`] used in SDXL, take a look at the [minSDXL](https://github.com/cloneofsimo/minSDXL) implementation which is written in PyTorch and directly compatible with 🤗 Diffusers. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl/#other-resources | #other-resources | .md | 58_14 |
<!--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/schedulers.md | https://huggingface.co/docs/diffusers/en/using-diffusers/schedulers/ | .md | 59_0 | |
[[open-in-colab]]
Diffusion pipelines are a collection of interchangeable schedulers and models that can be mixed and matched to tailor a pipeline to a specific use case. The scheduler encapsulates the entire denoising process such as the number of denoising steps and the algorithm for finding the denoised sample. A ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/schedulers.md | https://huggingface.co/docs/diffusers/en/using-diffusers/schedulers/#load-schedulers-and-models | #load-schedulers-and-models | .md | 59_1 |
Schedulers are defined by a configuration file that can be used by a variety of schedulers. Load a scheduler with the [`SchedulerMixin.from_pretrained`] method, and specify the `subfolder` parameter to load the configuration file into the correct subfolder of the pipeline repository.
For example, to load the [`DDIMSc... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/schedulers.md | https://huggingface.co/docs/diffusers/en/using-diffusers/schedulers/#load-a-scheduler | #load-a-scheduler | .md | 59_2 |
Schedulers have their own unique strengths and weaknesses, making it difficult to quantitatively compare which scheduler works best for a pipeline. You typically have to make a trade-off between denoising speed and denoising quality. We recommend trying out different schedulers to find one that works best for your use ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/schedulers.md | https://huggingface.co/docs/diffusers/en/using-diffusers/schedulers/#compare-schedulers | #compare-schedulers | .md | 59_3 |
To compare Flax schedulers, you need to additionally load the scheduler state into the model parameters. For example, let's change the default scheduler in [`FlaxStableDiffusionPipeline`] to use the super fast [`FlaxDPMSolverMultistepScheduler`].
> [!WARNING]
> The [`FlaxLMSDiscreteScheduler`] and [`FlaxDDPMScheduler... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/schedulers.md | https://huggingface.co/docs/diffusers/en/using-diffusers/schedulers/#flax-schedulers | #flax-schedulers | .md | 59_4 |
Models are loaded from the [`ModelMixin.from_pretrained`] method, which downloads and caches the latest version of the model weights and configurations. If the latest files are available in the local cache, [`~ModelMixin.from_pretrained`] reuses files in the cache instead of re-downloading them.
Models can be loaded ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/schedulers.md | https://huggingface.co/docs/diffusers/en/using-diffusers/schedulers/#models | #models | .md | 59_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/using-diffusers/sdxl_turbo.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl_turbo/ | .md | 60_0 | |
[[open-in-colab]]
SDXL Turbo is an adversarial time-distilled [Stable Diffusion XL](https://huggingface.co/papers/2307.01952) (SDXL) model capable
of running inference in as little as 1 step.
This guide will show you how to use SDXL-Turbo for text-to-image and image-to-image.
Before you begin, make sure you have ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl_turbo.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl_turbo/#stable-diffusion-xl-turbo | #stable-diffusion-xl-turbo | .md | 60_1 |
Model weights may be stored in separate subfolders on the Hub or locally, in which case, you should use the [`~StableDiffusionXLPipeline.from_pretrained`] method:
```py
from diffusers import AutoPipelineForText2Image
import torch
pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dt... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl_turbo.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl_turbo/#load-model-checkpoints | #load-model-checkpoints | .md | 60_2 |
For text-to-image, pass a text prompt. By default, SDXL Turbo generates a 512x512 image, and that resolution gives the best results. You can try setting the `height` and `width` parameters to 768x768 or 1024x1024, but you should expect quality degradations when doing so.
Make sure to set `guidance_scale` to 0.0 to di... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl_turbo.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl_turbo/#text-to-image | #text-to-image | .md | 60_3 |
For image-to-image generation, make sure that `num_inference_steps * strength` is larger or equal to 1.
The image-to-image pipeline will run for `int(num_inference_steps * strength)` steps, e.g. `0.5 * 2.0 = 1` step in
our example below.
```py
from diffusers import AutoPipelineForImage2Image
from diffusers.utils impo... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl_turbo.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl_turbo/#image-to-image | #image-to-image | .md | 60_4 |
- Compile the UNet if you are using PyTorch version 2.0 or higher. The first inference run will be very slow, but subsequent ones will be much faster.
```py
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
```
- When using the default VAE, keep it in `float32` to avoid costly `dtype` con... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/sdxl_turbo.md | https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl_turbo/#speed-up-sdxl-turbo-even-more | #speed-up-sdxl-turbo-even-more | .md | 60_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/using-diffusers/inference_with_lcm.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_lcm/ | .md | 61_0 | |
[[open-in-colab]]
[Latent Consistency Models (LCMs)](https://hf.co/papers/2310.04378) enable fast high-quality image generation by directly predicting the reverse diffusion process in the latent rather than pixel space. In other words, LCMs try to predict the noiseless image from the noisy image in contrast to typica... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_lcm.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_lcm/#latent-consistency-model | #latent-consistency-model | .md | 61_1 |
<hfoptions id="lcm-text2img">
<hfoption id="LCM">
To use LCMs, you need to load the LCM checkpoint for your supported model into [`UNet2DConditionModel`] and replace the scheduler with the [`LCMScheduler`]. Then you can use the pipeline as usual, and pass a text prompt to generate an image in just 4 steps.
A couple... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_lcm.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_lcm/#text-to-image | #text-to-image | .md | 61_2 |
<hfoptions id="lcm-img2img">
<hfoption id="LCM">
To use LCMs for image-to-image, you need to load the LCM checkpoint for your supported model into [`UNet2DConditionModel`] and replace the scheduler with the [`LCMScheduler`]. Then you can use the pipeline as usual, and pass a text prompt and initial image to generate ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_lcm.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_lcm/#image-to-image | #image-to-image | .md | 61_3 |
To use LCM-LoRAs for inpainting, you need to replace the scheduler with the [`LCMScheduler`] and load the LCM-LoRA weights with the [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] method. Then you can use the pipeline as usual, and pass a text prompt, initial image, and mask image to generate an image in ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_lcm.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_lcm/#inpainting | #inpainting | .md | 61_4 |
LCMs are compatible with adapters like LoRA, ControlNet, T2I-Adapter, and AnimateDiff. You can bring the speed of LCMs to these adapters to generate images in a certain style or condition the model on another input like a canny image. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_lcm.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_lcm/#adapters | #adapters | .md | 61_5 |
[LoRA](../using-diffusers/loading_adapters#lora) adapters can be rapidly finetuned to learn a new style from just a few images and plugged into a pretrained model to generate images in that style.
<hfoptions id="lcm-lora">
<hfoption id="LCM">
Load the LCM checkpoint for your supported model into [`UNet2DConditionMo... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_lcm.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_lcm/#lora | #lora | .md | 61_6 |
[ControlNet](./controlnet) are adapters that can be trained on a variety of inputs like canny edge, pose estimation, or depth. The ControlNet can be inserted into the pipeline to provide additional conditioning and control to the model for more accurate generation.
You can find additional ControlNet models trained on... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_lcm.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_lcm/#controlnet | #controlnet | .md | 61_7 |
[T2I-Adapter](./t2i_adapter) is an even more lightweight adapter than ControlNet, that provides an additional input to condition a pretrained model with. It is faster than ControlNet but the results may be slightly worse.
You can find additional T2I-Adapter checkpoints trained on other inputs in [TencentArc's](https:... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_lcm.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_lcm/#t2i-adapter | #t2i-adapter | .md | 61_8 |
[AnimateDiff](../api/pipelines/animatediff) is an adapter that adds motion to an image. It can be used with most Stable Diffusion models, effectively turning them into "video generation" models. Generating good results with a video model usually requires generating multiple frames (16-24), which can be very slow with a... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inference_with_lcm.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inference_with_lcm/#animatediff | #animatediff | .md | 61_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/stable_diffusion_jax_how_to.md | https://huggingface.co/docs/diffusers/en/using-diffusers/stable_diffusion_jax_how_to/ | .md | 62_0 | |
[[open-in-colab]]
🤗 Diffusers supports Flax for super fast inference on Google TPUs, such as those available in Colab, Kaggle or Google Cloud Platform. This guide shows you how to run inference with Stable Diffusion using JAX/Flax.
Before you begin, make sure you have the necessary libraries installed:
```py
# u... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/stable_diffusion_jax_how_to.md | https://huggingface.co/docs/diffusers/en/using-diffusers/stable_diffusion_jax_how_to/#jaxflax | #jaxflax | .md | 62_1 |
Flax is a functional framework, so models are stateless and parameters are stored outside of them. Loading a pretrained Flax pipeline returns *both* the pipeline and the model weights (or parameters). In this guide, you'll use `bfloat16`, a more efficient half-float type that is supported by TPUs (you can also use `flo... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/stable_diffusion_jax_how_to.md | https://huggingface.co/docs/diffusers/en/using-diffusers/stable_diffusion_jax_how_to/#load-a-model | #load-a-model | .md | 62_2 |
TPUs usually have 8 devices working in parallel, so let's use the same prompt for each device. This means you can perform inference on 8 devices at once, with each device generating one image. As a result, you'll get 8 images in the same amount of time it takes for one chip to generate a single image!
<Tip>
Learn m... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/stable_diffusion_jax_how_to.md | https://huggingface.co/docs/diffusers/en/using-diffusers/stable_diffusion_jax_how_to/#inference | #inference | .md | 62_3 |
You don't necessarily have to use the same prompt on all devices. For example, to generate 8 different prompts:
```python
prompts = [
"Labrador in the style of Hokusai",
"Painting of a squirrel skating in New York",
"HAL-9000 in the style of Van Gogh",
"Times Square under water, with fish and a dolphin swimming aroun... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/stable_diffusion_jax_how_to.md | https://huggingface.co/docs/diffusers/en/using-diffusers/stable_diffusion_jax_how_to/#using-different-prompts | #using-different-prompts | .md | 62_4 |
The Flax pipeline in 🤗 Diffusers automatically compiles the model and runs it in parallel on all available devices. Let's take a closer look at how that process works.
JAX parallelization can be done in multiple ways. The easiest one revolves around using the [`jax.pmap`](https://jax.readthedocs.io/en/latest/_autosu... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/stable_diffusion_jax_how_to.md | https://huggingface.co/docs/diffusers/en/using-diffusers/stable_diffusion_jax_how_to/#how-does-parallelization-work | #how-does-parallelization-work | .md | 62_5 |
To learn more about how JAX works with Stable Diffusion, you may be interested in reading:
* [Accelerating Stable Diffusion XL Inference with JAX on Cloud TPU v5e](https://hf.co/blog/sdxl_jax) | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/stable_diffusion_jax_how_to.md | https://huggingface.co/docs/diffusers/en/using-diffusers/stable_diffusion_jax_how_to/#resources | #resources | .md | 62_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/merge_loras.md | https://huggingface.co/docs/diffusers/en/using-diffusers/merge_loras/ | .md | 63_0 | |
It can be fun and creative to use multiple [LoRAs]((https://huggingface.co/docs/peft/conceptual_guides/adapter#low-rank-adaptation-lora)) together to generate something entirely new and unique. This works by merging multiple LoRA weights together to produce images that are a blend of different styles. Diffusers provide... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/merge_loras.md | https://huggingface.co/docs/diffusers/en/using-diffusers/merge_loras/#merge-loras | #merge-loras | .md | 63_1 |
The [`~loaders.PeftAdapterMixin.set_adapters`] method merges LoRA adapters by concatenating their weighted matrices. Use the adapter name to specify which LoRAs to merge, and the `adapter_weights` parameter to control the scaling for each LoRA. For example, if `adapter_weights=[0.5, 0.5]`, then the merged LoRA output i... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/merge_loras.md | https://huggingface.co/docs/diffusers/en/using-diffusers/merge_loras/#setadapters | #setadapters | .md | 63_2 |
> [!WARNING]
> This is an experimental method that adds PEFTs [add_weighted_adapter](https://huggingface.co/docs/peft/package_reference/lora#peft.LoraModel.add_weighted_adapter) method to Diffusers to enable more efficient merging methods. Check out this [issue](https://github.com/huggingface/diffusers/issues/6892) if ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/merge_loras.md | https://huggingface.co/docs/diffusers/en/using-diffusers/merge_loras/#addweightedadapter | #addweightedadapter | .md | 63_3 |
Both the [`~loaders.PeftAdapterMixin.set_adapters`] and [add_weighted_adapter](https://huggingface.co/docs/peft/package_reference/lora#peft.LoraModel.add_weighted_adapter) methods require loading the base model and the LoRA adapters separately which incurs some overhead. The [`~loaders.lora_base.LoraBaseMixin.fuse_lora... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/merge_loras.md | https://huggingface.co/docs/diffusers/en/using-diffusers/merge_loras/#fuselora | #fuselora | .md | 63_4 |
[torch.compile](../optimization/torch2.0#torchcompile) can speed up your pipeline even more, but the LoRA weights must be fused first and then unloaded. Typically, the UNet is compiled because it is such a computationally intensive component of the pipeline.
```py
from diffusers import DiffusionPipeline
import torch
... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/merge_loras.md | https://huggingface.co/docs/diffusers/en/using-diffusers/merge_loras/#torchcompile | #torchcompile | .md | 63_5 |
For more conceptual details about how each merging method works, take a look at the [🤗 PEFT welcomes new merging methods](https://huggingface.co/blog/peft_merging#concatenation-cat) blog post! | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/merge_loras.md | https://huggingface.co/docs/diffusers/en/using-diffusers/merge_loras/#next-steps | #next-steps | .md | 63_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/controlnet.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlnet/ | .md | 64_0 | |
ControlNet is a type of model for controlling image diffusion models by conditioning the model with an additional input image. There are many types of conditioning inputs (canny edge, user sketching, human pose, depth, and more) you can use to control a diffusion model. This is hugely useful because it affords you grea... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlnet.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlnet/#controlnet | #controlnet | .md | 64_1 |
For text-to-image, you normally pass a text prompt to the model. But with ControlNet, you can specify an additional conditioning input. Let's condition the model with a canny image, a white outline of an image on a black background. This way, the ControlNet can use the canny image as a control to guide the model to gen... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlnet.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlnet/#text-to-image | #text-to-image | .md | 64_2 |
For image-to-image, you'd typically pass an initial image and a prompt to the pipeline to generate a new image. With ControlNet, you can pass an additional conditioning input to guide the model. Let's condition the model with a depth map, an image which contains spatial information. This way, the ControlNet can use the... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlnet.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlnet/#image-to-image | #image-to-image | .md | 64_3 |
For inpainting, you need an initial image, a mask image, and a prompt describing what to replace the mask with. ControlNet models allow you to add another control image to condition a model with. Let’s condition the model with an inpainting mask. This way, the ControlNet can use the inpainting mask as a control to guid... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlnet.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlnet/#inpainting | #inpainting | .md | 64_4 |
[Guess mode](https://github.com/lllyasviel/ControlNet/discussions/188) does not require supplying a prompt to a ControlNet at all! This forces the ControlNet encoder to do its best to "guess" the contents of the input control map (depth map, pose estimation, canny edge, etc.).
Guess mode adjusts the scale of the outp... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlnet.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlnet/#guess-mode | #guess-mode | .md | 64_5 |
There aren't too many ControlNet models compatible with Stable Diffusion XL (SDXL) at the moment, but we've trained two full-sized ControlNet models for SDXL conditioned on canny edge detection and depth maps. We're also experimenting with creating smaller versions of these SDXL-compatible ControlNet models so it is ea... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlnet.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlnet/#controlnet-with-stable-diffusion-xl | #controlnet-with-stable-diffusion-xl | .md | 64_6 |
<Tip>
Replace the SDXL model with a model like [stable-diffusion-v1-5/stable-diffusion-v1-5](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5) to use multiple conditioning inputs with Stable Diffusion models.
</Tip>
You can compose multiple ControlNet conditionings from different image inputs to... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlnet.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlnet/#multicontrolnet | #multicontrolnet | .md | 64_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/using-diffusers/diffedit.md | https://huggingface.co/docs/diffusers/en/using-diffusers/diffedit/ | .md | 65_0 | |
[[open-in-colab]]
Image editing typically requires providing a mask of the area to be edited. DiffEdit automatically generates the mask for you based on a text query, making it easier overall to create a mask without image editing software. The DiffEdit algorithm works in three steps:
1. the diffusion model denoise... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/diffedit.md | https://huggingface.co/docs/diffusers/en/using-diffusers/diffedit/#diffedit | #diffedit | .md | 65_1 |
The source and target embeddings can be automatically generated with the [Flan-T5](https://huggingface.co/docs/transformers/model_doc/flan-t5) model instead of creating them manually.
Load the Flan-T5 model and tokenizer from the 🤗 Transformers library:
```py
import torch
from transformers import AutoTokenizer, T5... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/diffedit.md | https://huggingface.co/docs/diffusers/en/using-diffusers/diffedit/#generate-source-and-target-embeddings | #generate-source-and-target-embeddings | .md | 65_2 |
While you can use the `source_prompt` as a caption to help generate the partially inverted latents, you can also use the [BLIP](https://huggingface.co/docs/transformers/model_doc/blip) model to automatically generate a caption.
Load the BLIP model and processor from the 🤗 Transformers library:
```py
import torch
f... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/diffedit.md | https://huggingface.co/docs/diffusers/en/using-diffusers/diffedit/#generate-a-caption-for-inversion | #generate-a-caption-for-inversion | .md | 65_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/overview_techniques.md | https://huggingface.co/docs/diffusers/en/using-diffusers/overview_techniques/ | .md | 66_0 | |
The inference pipeline supports and enables a wide range of techniques that are divided into two categories:
* Pipeline functionality: these techniques modify the pipeline or extend it for other applications. For example, pipeline callbacks add new features to a pipeline and a pipeline can also be extended for distri... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/overview_techniques.md | https://huggingface.co/docs/diffusers/en/using-diffusers/overview_techniques/#overview | #overview | .md | 66_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/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/ | .md | 67_0 | |
Controlling outputs generated by diffusion models has been long pursued by the community and is now an active research topic. In many popular diffusion models, subtle changes in inputs, both images and text prompts, can drastically change outputs. In an ideal world we want to be able to control how semantics are preser... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#controlled-generation | #controlled-generation | .md | 67_1 |
[Paper](https://arxiv.org/abs/2211.09800)
[InstructPix2Pix](../api/pipelines/pix2pix) is fine-tuned from Stable Diffusion to support editing input images. It takes as inputs an image and a prompt describing an edit, and it outputs the edited image.
InstructPix2Pix has been explicitly trained to work well with [Instru... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#instructpix2pix | #instructpix2pix | .md | 67_2 |
[Paper](https://arxiv.org/abs/2302.03027)
[Pix2Pix Zero](../api/pipelines/pix2pix_zero) allows modifying an image so that one concept or subject is translated to another one while preserving general image semantics.
The denoising process is guided from one conceptual embedding towards another conceptual embedding. ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#pix2pix-zero | #pix2pix-zero | .md | 67_3 |
[Paper](https://arxiv.org/abs/2301.13826)
[Attend and Excite](../api/pipelines/attend_and_excite) allows subjects in the prompt to be faithfully represented in the final image.
A set of token indices are given as input, corresponding to the subjects in the prompt that need to be present in the image. During denoisi... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#attend-and-excite | #attend-and-excite | .md | 67_4 |
[Paper](https://arxiv.org/abs/2301.12247)
[SEGA](../api/pipelines/semantic_stable_diffusion) allows applying or removing one or more concepts from an image. The strength of the concept can also be controlled. I.e. the smile concept can be used to incrementally increase or decrease the smile of a portrait.
Similar t... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#semantic-guidance-sega | #semantic-guidance-sega | .md | 67_5 |
[Paper](https://arxiv.org/abs/2210.00939)
[Self-attention Guidance](../api/pipelines/self_attention_guidance) improves the general quality of images.
SAG provides guidance from predictions not conditioned on high-frequency details to fully conditioned images. The high frequency details are extracted out of the UNet... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#self-attention-guidance-sag | #self-attention-guidance-sag | .md | 67_6 |
[Project](https://huggingface.co/stabilityai/stable-diffusion-2-depth)
[Depth2Image](../api/pipelines/stable_diffusion/depth2img) is fine-tuned from Stable Diffusion to better preserve semantics for text guided image variation.
It conditions on a monocular depth estimate of the original image. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#depth2image | #depth2image | .md | 67_7 |
[Paper](https://arxiv.org/abs/2302.08113)
[MultiDiffusion Panorama](../api/pipelines/panorama) defines a new generation process over a pre-trained diffusion model. This process binds together multiple diffusion generation methods that can be readily applied to generate high quality and diverse images. Results adhere ... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#multidiffusion-panorama | #multidiffusion-panorama | .md | 67_8 |
In addition to pre-trained models, Diffusers has training scripts for fine-tuning models on user-provided data. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#fine-tuning-your-own-models | #fine-tuning-your-own-models | .md | 67_9 |
[Project](https://dreambooth.github.io/)
[DreamBooth](../training/dreambooth) fine-tunes a model to teach it about a new subject. I.e. a few pictures of a person can be used to generate images of that person in different styles. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#dreambooth | #dreambooth | .md | 67_10 |
[Paper](https://arxiv.org/abs/2208.01618)
[Textual Inversion](../training/text_inversion) fine-tunes a model to teach it about a new concept. I.e. a few pictures of a style of artwork can be used to generate images in that style. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#textual-inversion | #textual-inversion | .md | 67_11 |
[Paper](https://arxiv.org/abs/2302.05543)
[ControlNet](../api/pipelines/controlnet) is an auxiliary network which adds an extra condition.
There are 8 canonical pre-trained ControlNets trained on different conditionings such as edge detection, scribbles,
depth maps, and semantic segmentations. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#controlnet | #controlnet | .md | 67_12 |
[Prompt weighting](../using-diffusers/weighted_prompts) is a simple technique that puts more attention weight on certain parts of the text
input. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#prompt-weighting | #prompt-weighting | .md | 67_13 |
[Paper](https://arxiv.org/abs/2212.04488)
[Custom Diffusion](../training/custom_diffusion) only fine-tunes the cross-attention maps of a pre-trained
text-to-image diffusion model. It also allows for additionally performing Textual Inversion. It supports
multi-concept training by design. Like DreamBooth and Textual In... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#custom-diffusion | #custom-diffusion | .md | 67_14 |
[Paper](https://arxiv.org/abs/2303.08084)
The [text-to-image model editing pipeline](../api/pipelines/model_editing) helps you mitigate some of the incorrect implicit assumptions a pre-trained text-to-image
diffusion model might make about the subjects present in the input prompt. For example, if you prompt Stable Di... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#model-editing | #model-editing | .md | 67_15 |
[Paper](https://arxiv.org/abs/2210.11427)
[DiffEdit](../api/pipelines/diffedit) allows for semantic editing of input images along with
input prompts while preserving the original input images as much as possible. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#diffedit | #diffedit | .md | 67_16 |
[Paper](https://arxiv.org/abs/2302.08453)
[T2I-Adapter](../api/pipelines/stable_diffusion/adapter) is an auxiliary network which adds an extra condition.
There are 8 canonical pre-trained adapters trained on different conditionings such as edge detection, sketch,
depth maps, and semantic segmentations. | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#t2i-adapter | #t2i-adapter | .md | 67_17 |
[Paper](https://arxiv.org/abs/2307.10159)
[Fabric](https://github.com/huggingface/diffusers/tree/442017ccc877279bcf24fbe92f92d3d0def191b6/examples/community#stable-diffusion-fabric-pipeline) is a training-free
approach applicable to a wide range of popular diffusion models, which exploits
the self-attention layer pre... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/controlling_generation.md | https://huggingface.co/docs/diffusers/en/using-diffusers/controlling_generation/#fabric | #fabric | .md | 67_18 |
<!--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/write_own_pipeline.md | https://huggingface.co/docs/diffusers/en/using-diffusers/write_own_pipeline/ | .md | 68_0 | |
[[open-in-colab]]
🧨 Diffusers is designed to be a user-friendly and flexible toolbox for building diffusion systems tailored to your use-case. At the core of the toolbox are models and schedulers. While the [`DiffusionPipeline`] bundles these components together for convenience, you can also unbundle the pipeline an... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/write_own_pipeline.md | https://huggingface.co/docs/diffusers/en/using-diffusers/write_own_pipeline/#understanding-pipelines-models-and-schedulers | #understanding-pipelines-models-and-schedulers | .md | 68_1 |
A pipeline is a quick and easy way to run a model for inference, requiring no more than four lines of code to generate an image:
```py
>>> from diffusers import DDPMPipeline
>>> ddpm = DDPMPipeline.from_pretrained("google/ddpm-cat-256", use_safetensors=True).to("cuda")
>>> image = ddpm(num_inference_steps=25).images... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/write_own_pipeline.md | https://huggingface.co/docs/diffusers/en/using-diffusers/write_own_pipeline/#deconstruct-a-basic-pipeline | #deconstruct-a-basic-pipeline | .md | 68_2 |
Stable Diffusion is a text-to-image *latent diffusion* model. It is called a latent diffusion model because it works with a lower-dimensional representation of the image instead of the actual pixel space, which makes it more memory efficient. The encoder compresses the image into a smaller representation, and a decoder... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/write_own_pipeline.md | https://huggingface.co/docs/diffusers/en/using-diffusers/write_own_pipeline/#deconstruct-the-stable-diffusion-pipeline | #deconstruct-the-stable-diffusion-pipeline | .md | 68_3 |
The next step is to tokenize the text to generate embeddings. The text is used to condition the UNet model and steer the diffusion process towards something that resembles the input prompt.
<Tip>
💡 The `guidance_scale` parameter determines how much weight should be given to the prompt when generating an image.
<... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/write_own_pipeline.md | https://huggingface.co/docs/diffusers/en/using-diffusers/write_own_pipeline/#create-text-embeddings | #create-text-embeddings | .md | 68_4 |
Next, generate some initial random noise as a starting point for the diffusion process. This is the latent representation of the image, and it'll be gradually denoised. At this point, the `latent` image is smaller than the final image size but that's okay though because the model will transform it into the final 512x51... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/write_own_pipeline.md | https://huggingface.co/docs/diffusers/en/using-diffusers/write_own_pipeline/#create-random-noise | #create-random-noise | .md | 68_5 |
Start by scaling the input with the initial noise distribution, *sigma*, the noise scale value, which is required for improved schedulers like [`UniPCMultistepScheduler`]:
```py
>>> latents = latents * scheduler.init_noise_sigma
```
The last step is to create the denoising loop that'll progressively transform the p... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/write_own_pipeline.md | https://huggingface.co/docs/diffusers/en/using-diffusers/write_own_pipeline/#denoise-the-image | #denoise-the-image | .md | 68_6 |
The final step is to use the `vae` to decode the latent representation into an image and get the decoded output with `sample`:
```py
# scale and decode the image latents with vae
latents = 1 / 0.18215 * latents
with torch.no_grad():
image = vae.decode(latents).sample
```
Lastly, convert the image to a `PIL.Image` t... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/write_own_pipeline.md | https://huggingface.co/docs/diffusers/en/using-diffusers/write_own_pipeline/#decode-the-image | #decode-the-image | .md | 68_7 |
From basic to complex pipelines, you've seen that all you really need to write your own diffusion system is a denoising loop. The loop should set the scheduler's timesteps, iterate over them, and alternate between calling the UNet model to predict the noise residual and passing it to the scheduler to compute the previo... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/write_own_pipeline.md | https://huggingface.co/docs/diffusers/en/using-diffusers/write_own_pipeline/#next-steps | #next-steps | .md | 68_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/using-diffusers/consisid.md | https://huggingface.co/docs/diffusers/en/using-diffusers/consisid/ | .md | 69_0 | |
[ConsisID](https://github.com/PKU-YuanGroup/ConsisID) is an identity-preserving text-to-video generation model that keeps the face consistent in the generated video by frequency decomposition. The main features of ConsisID are:
- Frequency decomposition: The characteristics of the DiT architecture are analyzed from t... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/consisid.md | https://huggingface.co/docs/diffusers/en/using-diffusers/consisid/#consisid | #consisid | .md | 69_1 |
Model weights may be stored in separate subfolders on the Hub or locally, in which case, you should use the [`~DiffusionPipeline.from_pretrained`] method.
```python
# !pip install consisid_eva_clip insightface facexlib
import torch
from diffusers import ConsisIDPipeline
from diffusers.pipelines.consisid.consisid_util... | /Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/consisid.md | https://huggingface.co/docs/diffusers/en/using-diffusers/consisid/#load-model-checkpoints | #load-model-checkpoints | .md | 69_2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.