source stringclasses 273
values | url stringlengths 47 172 | file_type stringclasses 1
value | chunk stringlengths 1 512 | chunk_id stringlengths 5 9 |
|---|---|---|---|---|
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#padding-mask-crop | .md | Add the `padding_mask_crop` parameter to the pipeline call and set it to the desired padding value.
```py
import torch
from diffusers import AutoPipelineForInpainting
from diffusers.utils import load_image
from PIL import Image | 76_13_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#padding-mask-crop | .md | generator = torch.Generator(device='cuda').manual_seed(0)
pipeline = AutoPipelineForInpainting.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", torch_dtype=torch.float16).to('cuda')
base = load_image("https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/seashore.png")
mask = load_image("htt... | 76_13_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#padding-mask-crop | .md | image = pipeline("boat", image=base, mask_image=mask, strength=0.75, generator=generator, padding_mask_crop=32).images[0]
image
```
<div class="flex gap-4">
<div>
<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/baseline_inpaint.png"/>
<figcaption cl... | 76_13_4 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#padding-mask-crop | .md | <figcaption class="mt-2 text-center text-sm text-gray-500">default inpaint image</figcaption>
</div>
<div>
<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/padding_mask_crop_inpaint.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">inpa... | 76_13_5 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#chained-inpainting-pipelines | .md | [`AutoPipelineForInpainting`] can be chained with other 🤗 Diffusers pipelines to edit their outputs. This is often useful for improving the output quality from your other diffusion pipelines, and if you're using multiple pipelines, it can be more memory-efficient to chain them together to keep the outputs in latent sp... | 76_14_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#text-to-image-to-inpaint | .md | Chaining a text-to-image and inpainting pipeline allows you to inpaint the generated image, and you don't have to provide a base image to begin with. This makes it convenient to edit your favorite text-to-image outputs without having to generate an entirely new image.
Start with the text-to-image pipeline to create a... | 76_15_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#text-to-image-to-inpaint | .md | pipeline = AutoPipelineForText2Image.from_pretrained(
"stable-diffusion-v1-5/stable-diffusion-v1-5", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
)
pipeline.enable_model_cpu_offload()
# remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
pipeline.enable_xfor... | 76_15_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#text-to-image-to-inpaint | .md | text2image = pipeline("concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k").images[0]
```
Load the mask image of the output from above:
```py
mask_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_text... | 76_15_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#text-to-image-to-inpaint | .md | ```
And let's inpaint the masked area with a waterfall:
```py
pipeline = AutoPipelineForInpainting.from_pretrained(
"kandinsky-community/kandinsky-2-2-decoder-inpaint", torch_dtype=torch.float16
)
pipeline.enable_model_cpu_offload()
# remove following line if xFormers is not installed or you have PyTorch 2.0 or hig... | 76_15_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#text-to-image-to-inpaint | .md | prompt = "digital painting of a fantasy waterfall, cloudy"
image = pipeline(prompt=prompt, image=text2image, mask_image=mask_image).images[0]
make_image_grid([text2image, mask_image, image], rows=1, cols=3)
```
<div class="flex flex-row gap-4">
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/... | 76_15_4 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#text-to-image-to-inpaint | .md | <figcaption class="mt-2 text-center text-sm text-gray-500">text-to-image</figcaption>
</div>
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-text-chain-out.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">... | 76_15_5 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | You can also chain an inpainting pipeline before another pipeline like image-to-image or an upscaler to improve the quality.
Begin by inpainting an image:
```py
import torch
from diffusers import AutoPipelineForInpainting, AutoPipelineForImage2Image
from diffusers.utils import load_image, make_image_grid | 76_16_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | pipeline = AutoPipelineForInpainting.from_pretrained(
"runwayml/stable-diffusion-inpainting", torch_dtype=torch.float16, variant="fp16"
)
pipeline.enable_model_cpu_offload()
# remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
pipeline.enable_xformers_memory_efficient_attenti... | 76_16_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | # load base and mask image
init_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png")
mask_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png")
prompt = "concept art digital pai... | 76_16_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | # resize image to 1024x1024 for SDXL
image_inpainting = image_inpainting.resize((1024, 1024))
```
Now let's pass the image to another inpainting pipeline with SDXL's refiner model to enhance the image details and quality:
```py
pipeline = AutoPipelineForInpainting.from_pretrained(
"stabilityai/stable-diffusion-xl-r... | 76_16_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | # remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
pipeline.enable_xformers_memory_efficient_attention() | 76_16_4 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | image = pipeline(prompt=prompt, image=image_inpainting, mask_image=mask_image, output_type="latent").images[0]
```
<Tip> | 76_16_5 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | It is important to specify `output_type="latent"` in the pipeline to keep all the outputs in latent space to avoid an unnecessary decode-encode step. This only works if the chained pipelines are using the same VAE. For example, in the [Text-to-image-to-inpaint](#text-to-image-to-inpaint) section, Kandinsky 2.2 uses a d... | 76_16_6 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | work. But if you use Stable Diffusion v1.5 for both pipelines, then you can keep everything in latent space because they both use [`AutoencoderKL`]. | 76_16_7 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | </Tip>
Finally, you can pass this image to an image-to-image pipeline to put the finishing touches on it. It is more efficient to use the [`~AutoPipelineForImage2Image.from_pipe`] method to reuse the existing pipeline components, and avoid unnecessarily loading all the pipeline components into memory again.
```py
p... | 76_16_8 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | # remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
pipeline.enable_xformers_memory_efficient_attention() | 76_16_9 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | image = pipeline(prompt=prompt, image=image).images[0]
make_image_grid([init_image, mask_image, image_inpainting, image], rows=2, cols=2)
```
<div class="flex flex-row gap-4">
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpa... | 76_16_10 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | <figcaption class="mt-2 text-center text-sm text-gray-500">initial image</figcaption>
</div>
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-to-image-chain.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">... | 76_16_11 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | <figcaption class="mt-2 text-center text-sm text-gray-500">inpaint</figcaption>
</div>
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-to-image-final.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">image-... | 76_16_12 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#inpaint-to-image-to-image | .md | </div>
</div>
Image-to-image and inpainting are actually very similar tasks. Image-to-image generates a new image that resembles the existing provided image. Inpainting does the same thing, but it only transforms the image area defined by the mask and the rest of the image is unchanged. You can think of inpainting as... | 76_16_13 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#control-image-generation | .md | Getting an image to look exactly the way you want is challenging because the denoising process is random. While you can control certain aspects of generation by configuring parameters like `negative_prompt`, there are better and more efficient methods for controlling image generation. | 76_17_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#prompt-weighting | .md | Prompt weighting provides a quantifiable way to scale the representation of concepts in a prompt. You can use it to increase or decrease the magnitude of the text embedding vector for each concept in the prompt, which subsequently determines how much of each concept is generated. The [Compel](https://github.com/damian0... | 76_18_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#prompt-weighting | .md | syntax for scaling the prompt weights and generating the embeddings. Learn how to create the embeddings in the [Prompt weighting](../using-diffusers/weighted_prompts) guide. | 76_18_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#prompt-weighting | .md | Once you've generated the embeddings, pass them to the `prompt_embeds` (and `negative_prompt_embeds` if you're using a negative prompt) parameter in the [`AutoPipelineForInpainting`]. The embeddings replace the `prompt` parameter:
```py
import torch
from diffusers import AutoPipelineForInpainting
from diffusers.utils... | 76_18_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#prompt-weighting | .md | pipeline = AutoPipelineForInpainting.from_pretrained(
"runwayml/stable-diffusion-inpainting", torch_dtype=torch.float16,
)
pipeline.enable_model_cpu_offload()
# remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
pipeline.enable_xformers_memory_efficient_attention() | 76_18_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#prompt-weighting | .md | image = pipeline(prompt_embeds=prompt_embeds, # generated from Compel
negative_prompt_embeds=negative_prompt_embeds, # generated from Compel
image=init_image,
mask_image=mask_image
).images[0]
make_image_grid([init_image, mask_image, image], rows=1, cols=3)
``` | 76_18_4 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | ControlNet models are used with other diffusion models like Stable Diffusion, and they provide an even more flexible and accurate way to control how an image is generated. A ControlNet accepts an additional conditioning image input that guides the diffusion model to preserve the features in it.
For example, let's con... | 76_19_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | ```py
import torch
import numpy as np
from diffusers import ControlNetModel, StableDiffusionControlNetInpaintPipeline
from diffusers.utils import load_image, make_image_grid | 76_19_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | # load ControlNet
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_inpaint", torch_dtype=torch.float16, variant="fp16") | 76_19_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | # pass ControlNet to the pipeline
pipeline = StableDiffusionControlNetInpaintPipeline.from_pretrained(
"runwayml/stable-diffusion-inpainting", controlnet=controlnet, torch_dtype=torch.float16, variant="fp16"
)
pipeline.enable_model_cpu_offload()
# remove following line if xFormers is not installed or you have PyTorch 2... | 76_19_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | # load base and mask image
init_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png")
mask_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png") | 76_19_4 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | # prepare control image
def make_inpaint_condition(init_image, mask_image):
init_image = np.array(init_image.convert("RGB")).astype(np.float32) / 255.0
mask_image = np.array(mask_image.convert("L")).astype(np.float32) / 255.0 | 76_19_5 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | assert init_image.shape[0:1] == mask_image.shape[0:1], "image and image_mask must have the same image size"
init_image[mask_image > 0.5] = -1.0 # set as masked pixel
init_image = np.expand_dims(init_image, 0).transpose(0, 3, 1, 2)
init_image = torch.from_numpy(init_image)
return init_image | 76_19_6 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | control_image = make_inpaint_condition(init_image, mask_image)
```
Now generate an image from the base, mask and control images. You'll notice features of the base image are strongly preserved in the generated image.
```py
prompt = "concept art digital painting of an elven castle, inspired by lord of the rings, hig... | 76_19_7 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image, control_image=control_image).images[0]
make_image_grid([init_image, mask_image, PIL.Image.fromarray(np.uint8(control_image[0][0])).convert('RGB'), image], rows=2, cols=2)
```
You can take this a step further and chain it with an image-to-image p... | 76_19_8 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | pipeline = AutoPipelineForImage2Image.from_pretrained(
"nitrosocke/elden-ring-diffusion", torch_dtype=torch.float16,
)
pipeline.enable_model_cpu_offload()
# remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
pipeline.enable_xformers_memory_efficient_attention()
prompt = "eld... | 76_19_9 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | image_elden_ring = pipeline(prompt, negative_prompt=negative_prompt, image=image).images[0]
make_image_grid([init_image, mask_image, image, image_elden_ring], rows=2, cols=2)
```
<div class="flex flex-row gap-4">
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentati... | 76_19_10 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | <figcaption class="mt-2 text-center text-sm text-gray-500">initial image</figcaption>
</div>
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-controlnet.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">Cont... | 76_19_11 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#controlnet | .md | <figcaption class="mt-2 text-center text-sm text-gray-500">ControlNet inpaint</figcaption>
</div>
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-img2img.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">im... | 76_19_12 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#optimize | .md | It can be difficult and slow to run diffusion models if you're resource constrained, but it doesn't have to be with a few optimization tricks. One of the biggest (and easiest) optimizations you can enable is switching to memory-efficient attention. If you're using PyTorch 2.0, [scaled-dot product attention](../optimiza... | 76_20_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#optimize | .md | is automatically enabled and you don't need to do anything else. For non-PyTorch 2.0 users, you can install and use [xFormers](../optimization/xformers)'s implementation of memory-efficient attention. Both options reduce memory usage and accelerate inference. | 76_20_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#optimize | .md | You can also offload the model to the CPU to save even more memory:
```diff
+ pipeline.enable_xformers_memory_efficient_attention()
+ pipeline.enable_model_cpu_offload()
```
To speed-up your inference code even more, use [`torch_compile`](../optimization/torch2.0#torchcompile). You should wrap `torch.compile` aroun... | 76_20_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/inpaint.md | https://huggingface.co/docs/diffusers/en/using-diffusers/inpaint/#optimize | .md | ```py
pipeline.unet = torch.compile(pipeline.unet, mode="reduce-overhead", fullgraph=True)
```
Learn more in the [Reduce memory usage](../optimization/memory) and [Torch 2.0](../optimization/torch2.0) guides. | 76_20_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/ | .md | <!--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... | 77_0_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/ | .md | an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
--> | 77_0_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#perturbed-attention-guidance | .md | [Perturbed-Attention Guidance (PAG)](https://ku-cvlab.github.io/Perturbed-Attention-Guidance/) is a new diffusion sampling guidance that improves sample quality across both unconditional and conditional settings, achieving this without requiring further training or the integration of external modules. PAG is designed t... | 77_1_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#perturbed-attention-guidance | .md | throughout the denoising process by considering the self-attention mechanisms' ability to capture structural information. It involves generating intermediate samples with degraded structure by substituting selected self-attention maps in diffusion U-Net with an identity matrix, and guiding the denoising process away fr... | 77_1_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#perturbed-attention-guidance | .md | This guide will show you how to use PAG for various tasks and use cases. | 77_1_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | You can apply PAG to the [`StableDiffusionXLPipeline`] for tasks such as text-to-image, image-to-image, and inpainting. To enable PAG for a specific task, load the pipeline using the [AutoPipeline](../api/pipelines/auto_pipeline) API with the `enable_pag=True` flag and the `pag_applied_layers` argument.
> [!TIP] | 77_2_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | > [!TIP]
> 🤗 Diffusers currently only supports using PAG with selected SDXL pipelines and [`PixArtSigmaPAGPipeline`]. But feel free to open a [feature request](https://github.com/huggingface/diffusers/issues/new/choose) if you want to add PAG support to a new pipeline!
<hfoptions id="tasks">
<hfoption id="Text-to-im... | 77_2_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | pipeline = AutoPipelineForText2Image.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
enable_pag=True,
pag_applied_layers=["mid"],
torch_dtype=torch.float16
)
pipeline.enable_model_cpu_offload()
```
> [!TIP] | 77_2_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | enable_pag=True,
pag_applied_layers=["mid"],
torch_dtype=torch.float16
)
pipeline.enable_model_cpu_offload()
```
> [!TIP]
> The `pag_applied_layers` argument allows you to specify which layers PAG is applied to. Additionally, you can use `set_pag_applied_layers` method to update these layers after the pipeline has be... | 77_2_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | If you already have a pipeline created and loaded, you can enable PAG on it using the `from_pipe` API with the `enable_pag` flag. Internally, a PAG pipeline is created based on the pipeline and task you specified. In the example below, since we used `AutoPipelineForText2Image` and passed a `StableDiffusionXLPipeline`, ... | 77_2_4 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | created accordingly. Note that this does not require additional memory, and you will have both `StableDiffusionXLPipeline` and `StableDiffusionXLPAGPipeline` loaded and ready to use. You can read more about the `from_pipe` API and how to reuse pipelines in diffuser [here](https://huggingface.co/docs/diffusers/using-di... | 77_2_5 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | ```py
pipeline_sdxl = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16)
pipeline = AutoPipelineForText2Image.from_pipe(pipeline_sdxl, enable_pag=True)
``` | 77_2_6 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | ```
To generate an image, you will also need to pass a `pag_scale`. When `pag_scale` increases, images gain more semantically coherent structures and exhibit fewer artifacts. However overly large guidance scale can lead to smoother textures and slight saturation in the images, similarly to CFG. `pag_scale=3.0` is use... | 77_2_7 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | ```py
prompt = "an insect robot preparing a delicious meal, anime style" | 77_2_8 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | for pag_scale in [0.0, 3.0]:
generator = torch.Generator(device="cpu").manual_seed(0)
images = pipeline(
prompt=prompt,
num_inference_steps=25,
guidance_scale=7.0,
generator=generator,
pag_scale=pag_scale,
).images
```
<div class="flex flex-row gap-4">
<div class="flex-1">
<img class="rounded-xl" src="https://hugging... | 77_2_9 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | <figcaption class="mt-2 text-center text-sm text-gray-500">generated image without PAG</figcaption>
</div>
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/pag_3.0_cfg_7.0_mid.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">generated ... | 77_2_10 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | </div>
</div>
</hfoption>
<hfoption id="Image-to-image">
You can use PAG with image-to-image pipelines.
```py
from diffusers import AutoPipelineForImage2Image
from diffusers.utils import load_image
import torch | 77_2_11 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | pipeline = AutoPipelineForImage2Image.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
enable_pag=True,
pag_applied_layers=["mid"],
torch_dtype=torch.float16
)
pipeline.enable_model_cpu_offload()
```
If you already have a image-to-image pipeline and would like enable PAG on it, you can run this
```py
pi... | 77_2_12 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | pipeline = AutoPipelineForImage2Image.from_pipe(pipeline_t2i, enable_pag=True)
```
It is also very easy to directly switch from a text-to-image pipeline to PAG enabled image-to-image pipeline
```py
pipeline_pag = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch... | 77_2_13 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | pipeline = AutoPipelineForImage2Image.from_pipe(pipeline_t2i, enable_pag=True)
```
If you have a PAG enabled text-to-image pipeline, you can directly switch to a image-to-image pipeline with PAG still enabled
```py
pipeline_pag = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", ... | 77_2_14 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl-text2img.png"
init_image = load_image(url)
prompt = "a dog catching a frisbee in the jungle" | 77_2_15 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | generator = torch.Generator(device="cpu").manual_seed(0)
image = pipeline(
prompt,
image=init_image,
strength=0.8,
guidance_scale=guidance_scale,
pag_scale=pag_scale,
generator=generator).images[0]
```
</hfoption>
<hfoption id="Inpainting">
```py
from diffusers import AutoPipelineForInpainting
from diffusers.utils ... | 77_2_16 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | pipeline = AutoPipelineForInpainting.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
enable_pag=True,
torch_dtype=torch.float16
)
pipeline.enable_model_cpu_offload()
```
You can enable PAG on an exisiting inpainting pipeline like this
```py
pipeline_inpaint = AutoPipelineForInpaiting.from_pretrained("s... | 77_2_17 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | pipeline = AutoPipelineForInpaiting.from_pipe(pipeline_inpaint, enable_pag=True)
```
This still works when your pipeline has a different task:
```py
pipeline_t2i = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16)
pipeline = AutoPipelineForInpaiting.fro... | 77_2_18 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | pipeline = AutoPipelineForInpaiting.from_pipe(pipeline_t2i, enable_pag=True)
```
Let's generate an image!
```py
img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusi... | 77_2_19 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#general-tasks | .md | prompt = "A majestic tiger sitting on a bench"
pag_scales = 3.0
guidance_scales = 7.5
generator = torch.Generator(device="cpu").manual_seed(1)
images = pipeline(
prompt=prompt,
image=init_image,
mask_image=mask_image,
strength=0.8,
num_inference_steps=50,
guidance_scale=guidance_scale,
generator=generator,
pag_scale... | 77_2_20 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-controlnet | .md | To use PAG with ControlNet, first create a `controlnet`. Then, pass the `controlnet` and other PAG arguments to the `from_pretrained` method of the AutoPipeline for the specified task.
```py
from diffusers import AutoPipelineForText2Image, ControlNetModel
import torch
controlnet = ControlNetModel.from_pretrained(
"d... | 77_3_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-controlnet | .md | pipeline = AutoPipelineForText2Image.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
controlnet=controlnet,
enable_pag=True,
pag_applied_layers="mid",
torch_dtype=torch.float16
)
pipeline.enable_model_cpu_offload()
```
<Tip>
If you already have a controlnet pipeline and want to enable PAG, you can use ... | 77_3_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-controlnet | .md | </Tip>
You can use the pipeline in the same way you normally use ControlNet pipelines, with the added option to specify a `pag_scale` parameter. Note that PAG works well for unconditional generation. In this example, we will generate an image without a prompt.
```py
from diffusers.utils import load_image
canny_imag... | 77_3_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-controlnet | .md | for pag_scale in [0.0, 3.0]:
generator = torch.Generator(device="cpu").manual_seed(1)
images = pipeline(
prompt="",
controlnet_conditioning_scale=controlnet_conditioning_scale,
image=canny_image,
num_inference_steps=50,
guidance_scale=0,
generator=generator,
pag_scale=pag_scale,
).images
images[0]
```
<div class="fle... | 77_3_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-controlnet | .md | <img class="rounded-xl" src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/pag_0.0_controlnet.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">generated image without PAG</figcaption>
</div>
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/YiYiXu/te... | 77_3_4 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-ip-adapter | .md | [IP-Adapter](https://hf.co/papers/2308.06721) is a popular model that can be plugged into diffusion models to enable image prompting without any changes to the underlying model. You can enable PAG on a pipeline with IP-Adapter loaded.
```py
from diffusers import AutoPipelineForText2Image
from diffusers.utils import l... | 77_4_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-ip-adapter | .md | image_encoder = CLIPVisionModelWithProjection.from_pretrained(
"h94/IP-Adapter",
subfolder="models/image_encoder",
torch_dtype=torch.float16
)
pipeline = AutoPipelineForText2Image.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
image_encoder=image_encoder,
enable_pag=True,
torch_dtype=torch.float16
).to("... | 77_4_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-ip-adapter | .md | pag_scales = 5.0
ip_adapter_scales = 0.8
image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_diner.png") | 77_4_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-ip-adapter | .md | pipeline.set_ip_adapter_scale(ip_adapter_scale)
generator = torch.Generator(device="cpu").manual_seed(0)
images = pipeline(
prompt="a polar bear sitting in a chair drinking a milkshake",
ip_adapter_image=image,
negative_prompt="deformed, ugly, wrong proportion, low res, bad anatomy, worst quality, low quality",
num_inf... | 77_4_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-ip-adapter | .md | ```
PAG reduces artifacts and improves the overall compposition.
<div class="flex flex-row gap-4">
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/pag_0.0_ipa_0.8.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">generated image wi... | 77_4_4 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pag-with-ip-adapter | .md | <img class="rounded-xl" src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/pag_5.0_ipa_0.8.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">generated image with PAG</figcaption>
</div>
</div> | 77_4_5 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pagappliedlayers | .md | The `pag_applied_layers` argument allows you to specify which layers PAG is applied to. By default, it applies only to the mid blocks. Changing this setting will significantly impact the output. You can use the `set_pag_applied_layers` method to adjust the PAG layers after the pipeline is created, helping you find the ... | 77_5_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pagappliedlayers | .md | ```py
prompt = "an insect robot preparing a delicious meal, anime style"
pipeline.set_pag_applied_layers(pag_layers)
generator = torch.Generator(device="cpu").manual_seed(0)
images = pipeline(
prompt=prompt,
num_inference_steps=25,
guidance_scale=guidance_scale,
generator=generator,
pag_scale=pag_scale,
).images
images... | 77_5_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pagappliedlayers | .md | generator=generator,
pag_scale=pag_scale,
).images
images[0]
```
<div class="flex flex-row gap-4">
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/pag_3.0_cfg_7.0_down2_up1a0.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">down.blo... | 77_5_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/pag.md | https://huggingface.co/docs/diffusers/en/using-diffusers/pag/#pagappliedlayers | .md | </div>
<div class="flex-1">
<img class="rounded-xl" src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/pag_3.0_cfg_7.0_down2.png"/>
<figcaption class="mt-2 text-center text-sm text-gray-500">down.block_2</figcaption>
</div>
</div> | 77_5_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/depth2img.md | https://huggingface.co/docs/diffusers/en/using-diffusers/depth2img/ | .md | <!--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... | 78_0_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/depth2img.md | https://huggingface.co/docs/diffusers/en/using-diffusers/depth2img/ | .md | an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
--> | 78_0_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/depth2img.md | https://huggingface.co/docs/diffusers/en/using-diffusers/depth2img/#text-guided-depth-to-image-generation | .md | [[open-in-colab]]
The [`StableDiffusionDepth2ImgPipeline`] lets you pass a text prompt and an initial image to condition the generation of new images. In addition, you can also pass a `depth_map` to preserve the image structure. If no `depth_map` is provided, the pipeline automatically predicts the depth via an integ... | 78_1_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/depth2img.md | https://huggingface.co/docs/diffusers/en/using-diffusers/depth2img/#text-guided-depth-to-image-generation | .md | Start by creating an instance of the [`StableDiffusionDepth2ImgPipeline`]:
```python
import torch
from diffusers import StableDiffusionDepth2ImgPipeline
from diffusers.utils import load_image, make_image_grid | 78_1_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/depth2img.md | https://huggingface.co/docs/diffusers/en/using-diffusers/depth2img/#text-guided-depth-to-image-generation | .md | pipeline = StableDiffusionDepth2ImgPipeline.from_pretrained(
"stabilityai/stable-diffusion-2-depth",
torch_dtype=torch.float16,
use_safetensors=True,
).to("cuda")
```
Now pass your prompt to the pipeline. You can also pass a `negative_prompt` to prevent certain words from guiding how an image is generated:
```pytho... | 78_1_2 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/depth2img.md | https://huggingface.co/docs/diffusers/en/using-diffusers/depth2img/#text-guided-depth-to-image-generation | .md | init_image = load_image(url)
prompt = "two tigers"
negative_prompt = "bad, deformed, ugly, bad anatomy"
image = pipeline(prompt=prompt, image=init_image, negative_prompt=negative_prompt, strength=0.7).images[0]
make_image_grid([init_image, image], rows=1, cols=2)
```
| Input ... | 78_1_3 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/depth2img.md | https://huggingface.co/docs/diffusers/en/using-diffusers/depth2img/#text-guided-depth-to-image-generation | .md | |---------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/... | 78_1_4 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/cogvideox.md | https://huggingface.co/docs/diffusers/en/using-diffusers/cogvideox/ | .md | <!--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... | 79_0_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/cogvideox.md | https://huggingface.co/docs/diffusers/en/using-diffusers/cogvideox/ | .md | an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
--> | 79_0_1 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/cogvideox.md | https://huggingface.co/docs/diffusers/en/using-diffusers/cogvideox/#cogvideox | .md | CogVideoX is a text-to-video generation model focused on creating more coherent videos aligned with a prompt. It achieves this using several methods.
- a 3D variational autoencoder that compresses videos spatially and temporally, improving compression rate and video accuracy.
- an expert transformer block to help a... | 79_1_0 |
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/using-diffusers/cogvideox.md | https://huggingface.co/docs/diffusers/en/using-diffusers/cogvideox/#load-model-checkpoints | .md | Model weights may be stored in separate subfolders on the Hub or locally, in which case, you should use the [`~DiffusionPipeline.from_pretrained`] method.
```py
from diffusers import CogVideoXPipeline, CogVideoXImageToVideoPipeline
pipe = CogVideoXPipeline.from_pretrained(
"THUDM/CogVideoX-2b",
torch_dtype=torch.floa... | 79_2_0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.