Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
42d49af
integrated sdxl for the text2video-zero pipeline
Aug 21, 2023
7221015
Merge branch 'main' of https://github.com/huggingface/diffusers into …
Aug 21, 2023
4469455
make fix-copies
Aug 23, 2023
e00f93e
Merge branch 'main' of https://github.com/huggingface/diffusers into …
Aug 25, 2023
0591367
fixed CI issues
Aug 25, 2023
14479ad
make fix-copies
Aug 25, 2023
fe50922
Merge branch 'main' of https://github.com/huggingface/diffusers into …
Aug 25, 2023
b19d32d
added docs and `copied from` statements
vahramtadevosyan Aug 28, 2023
cf7aa3b
added fast tests
vahramtadevosyan Aug 29, 2023
97aa3d2
synced with original code
vahramtadevosyan Aug 29, 2023
c1e86e8
Merge branch 'main' into text2video-zero-sdxl
vahramtadevosyan Aug 29, 2023
c8e2838
Merge branch 'text2video-zero-sdxl' of github.com:vahramtadevosyan/di…
vahramtadevosyan Aug 29, 2023
71fe6cc
made a small change in docs
vahramtadevosyan Aug 29, 2023
898f42e
quality+style check fix
vahramtadevosyan Aug 29, 2023
20bb7aa
updated docs. added controlnet inference with sdxl
vahramtadevosyan Aug 30, 2023
40d9ad3
Merge branch 'main' of https://github.com/huggingface/diffusers into …
vahramtadevosyan Aug 30, 2023
1794494
added device compatibility for fast tests
vahramtadevosyan Aug 30, 2023
dc08a70
Merge branch 'main' of https://github.com/huggingface/diffusers into …
vahramtadevosyan Aug 30, 2023
6aa65f1
fixed docstrings
vahramtadevosyan Aug 31, 2023
94ffc44
Merge branch 'main' of https://github.com/huggingface/diffusers into …
vahramtadevosyan Aug 31, 2023
d3288b0
changing vae upcasting
vahramtadevosyan Aug 31, 2023
804d9f0
remove torch.empty_cache to speed up inference
vahramtadevosyan Aug 31, 2023
f8ae9aa
Merge branch 'main' into text2video-zero-sdxl
vahramtadevosyan Aug 31, 2023
8350c85
Merge branch 'main' into text2video-zero-sdxl
vahramtadevosyan Sep 11, 2023
9698d16
made fast tests to run on dummy models only, fixed copied from statem…
vahramtadevosyan Sep 11, 2023
357e87f
fixed testing utils imports
vahramtadevosyan Sep 11, 2023
1de7d55
Added bullet points for SDXL support
vahramtadevosyan Sep 12, 2023
03c9178
Merge branch 'main' of https://github.com/huggingface/diffusers into …
vahramtadevosyan Sep 12, 2023
2159e73
fixed formatting & quality
vahramtadevosyan Sep 12, 2023
2e73398
Update tests/pipelines/text_to_video/test_text_to_video_zero_sdxl.py
vahramtadevosyan Sep 18, 2023
ec99303
Update tests/pipelines/text_to_video/test_text_to_video_zero_sdxl.py
vahramtadevosyan Sep 18, 2023
972b172
Merge branch 'main' into text2video-zero-sdxl
vahramtadevosyan Sep 18, 2023
0c59ff9
Merge branch 'main' into text2video-zero-sdxl
patrickvonplaten Sep 19, 2023
3804a64
fixed minor error for merging
vahramtadevosyan Oct 17, 2023
d9737aa
Merge branch 'main' of https://github.com/huggingface/diffusers into …
vahramtadevosyan Oct 17, 2023
b552865
fixed updates of sdxl
vahramtadevosyan Oct 17, 2023
eddf8a8
made fast tests inherit from `PipelineTesterMixin` and run in 3-4secs…
vahramtadevosyan Oct 18, 2023
0304d75
Merge branch 'main' of https://github.com/huggingface/diffusers into …
vahramtadevosyan Oct 18, 2023
2635868
make style && make quality
vahramtadevosyan Oct 18, 2023
9f4c8cd
reimplemented fast tests w/o default attn processor
vahramtadevosyan Oct 27, 2023
ba65002
make style & make quality
vahramtadevosyan Oct 27, 2023
a32641d
Merge branch 'main' of github.com:huggingface/diffusers into text2vid…
vahramtadevosyan Oct 27, 2023
0a919f9
make fix-copies
vahramtadevosyan Oct 27, 2023
deae67c
make fix-copies
vahramtadevosyan Oct 27, 2023
3167053
fixed docs
vahramtadevosyan Oct 27, 2023
fdc3ee8
make style & make quality & make fix-copies
vahramtadevosyan Oct 27, 2023
371093d
Merge branch 'main' into text2video-zero-sdxl
DN6 Oct 30, 2023
fa14652
bug fix in cross attention
vahramtadevosyan Oct 30, 2023
028d1f5
Merge branch 'main' into text2video-zero-sdxl
DN6 Nov 10, 2023
de7c207
make style && make quality
vahramtadevosyan Nov 10, 2023
78e8a44
make fix-copies
vahramtadevosyan Nov 10, 2023
b22091e
Merge branch 'main' into text2video-zero-sdxl
patrickvonplaten Nov 20, 2023
9ee0304
Merge branch 'main' of github.com:huggingface/diffusers into text2vid…
vahramtadevosyan Nov 21, 2023
d395fa0
Merge branch 'text2video-zero-sdxl' of github.com:vahramtadevosyan/di…
vahramtadevosyan Nov 21, 2023
52461ae
Merge branch 'main' of github.com:huggingface/diffusers into text2vid…
vahramtadevosyan Nov 21, 2023
2ae9893
fix gpu issues
vahramtadevosyan Nov 22, 2023
ed78680
make fix-copies
vahramtadevosyan Nov 22, 2023
3890c34
Merge branch 'main' into text2video-zero-sdxl
patrickvonplaten Nov 27, 2023
46ac35e
Merge branch 'main' of github.com:huggingface/diffusers into text2vid…
vahramtadevosyan Nov 27, 2023
0f2c69e
Merge branch 'main' of github.com:huggingface/diffusers into text2vid…
vahramtadevosyan Nov 28, 2023
f60409c
updated pipeline signature
vahramtadevosyan Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion docs/source/en/api/pipelines/text_to_video_zero.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ imageio.mimsave("video.mp4", result, fps=4)
```


- #### SDXL Support
In order to use the SDXL model when generating a video from prompt, use the `TextToVideoZeroSDXLPipeline` pipeline:

```python
import torch
from diffusers import TextToVideoZeroSDXLPipeline

model_id = "stabilityai/stable-diffusion-xl-base-1.0"
pipe = TextToVideoZeroSDXLPipeline.from_pretrained(
model_id, torch_dtype=torch.float16, variant="fp16", use_safetensors=True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work out of the box?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm good catch. @vahramtadevosyan Can you confirm this works out of the box with SDXL base?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DN6 @patrickvonplaten can you explain what do you mean by working out of the box?

).to("cuda")
```

### Text-To-Video with Pose Control
To generate a video from prompt with additional pose control

Expand Down Expand Up @@ -141,7 +154,33 @@ To generate a video from prompt with additional pose control
result = pipe(prompt=[prompt] * len(pose_images), image=pose_images, latents=latents).images
imageio.mimsave("video.mp4", result, fps=4)
```

- #### SDXL Support

Since our attention processor also works with SDXL, it can be utilized to generate a video from prompt using ControlNet models powered by SDXL:
```python
import torch
from diffusers import StableDiffusionXLControlNetPipeline, ControlNetModel
from diffusers.pipelines.text_to_video_synthesis.pipeline_text_to_video_zero import CrossFrameAttnProcessor

controlnet_model_id = 'thibaud/controlnet-openpose-sdxl-1.0'
model_id = 'stabilityai/stable-diffusion-xl-base-1.0'

controlnet = ControlNetModel.from_pretrained(controlnet_model_id, torch_dtype=torch.float16)
pipe = StableDiffusionControlNetPipeline.from_pretrained(
model_id, controlnet=controlnet, torch_dtype=torch.float16
).to('cuda')

# Set the attention processor
pipe.unet.set_attn_processor(CrossFrameAttnProcessor(batch_size=2))
pipe.controlnet.set_attn_processor(CrossFrameAttnProcessor(batch_size=2))

# fix latents for all frames
latents = torch.randn((1, 4, 128, 128), device="cuda", dtype=torch.float16).repeat(len(pose_images), 1, 1, 1)

prompt = "Darth Vader dancing in a desert"
result = pipe(prompt=[prompt] * len(pose_images), image=pose_images, latents=latents).images
imageio.mimsave("video.mp4", result, fps=4)
```

### Text-To-Video with Edge Control

Expand Down Expand Up @@ -253,5 +292,10 @@ Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers)
- all
- __call__

## TextToVideoZeroSDXLPipeline
[[autodoc]] TextToVideoZeroSDXLPipeline
- all
- __call__

## TextToVideoPipelineOutput
[[autodoc]] pipelines.text_to_video_synthesis.pipeline_text_to_video_zero.TextToVideoPipelineOutput
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add TextToVideoZeroSDXLPipeline in the docs too otherwise they won't reflect :-).

2 changes: 2 additions & 0 deletions src/diffusers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
"StableUnCLIPPipeline",
"TextToVideoSDPipeline",
"TextToVideoZeroPipeline",
"TextToVideoZeroSDXLPipeline",
"UnCLIPImageVariationPipeline",
"UnCLIPPipeline",
"UniDiffuserModel",
Expand Down Expand Up @@ -628,6 +629,7 @@
StableUnCLIPPipeline,
TextToVideoSDPipeline,
TextToVideoZeroPipeline,
TextToVideoZeroSDXLPipeline,
UnCLIPImageVariationPipeline,
UnCLIPPipeline,
UniDiffuserModel,
Expand Down
2 changes: 2 additions & 0 deletions src/diffusers/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
_import_structure["text_to_video_synthesis"] = [
"TextToVideoSDPipeline",
"TextToVideoZeroPipeline",
"TextToVideoZeroSDXLPipeline",
"VideoToVideoSDPipeline",
]
_import_structure["unclip"] = ["UnCLIPImageVariationPipeline", "UnCLIPPipeline"]
Expand Down Expand Up @@ -386,6 +387,7 @@
from .text_to_video_synthesis import (
TextToVideoSDPipeline,
TextToVideoZeroPipeline,
TextToVideoZeroSDXLPipeline,
VideoToVideoSDPipeline,
)
from .unclip import UnCLIPImageVariationPipeline, UnCLIPPipeline
Expand Down
2 changes: 2 additions & 0 deletions src/diffusers/pipelines/text_to_video_synthesis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
_import_structure["pipeline_text_to_video_synth"] = ["TextToVideoSDPipeline"]
_import_structure["pipeline_text_to_video_synth_img2img"] = ["VideoToVideoSDPipeline"]
_import_structure["pipeline_text_to_video_zero"] = ["TextToVideoZeroPipeline"]
_import_structure["pipeline_text_to_video_zero_sdxl"] = ["TextToVideoZeroSDXLPipeline"]


if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
Expand All @@ -38,6 +39,7 @@
from .pipeline_text_to_video_synth import TextToVideoSDPipeline
from .pipeline_text_to_video_synth_img2img import VideoToVideoSDPipeline
from .pipeline_text_to_video_zero import TextToVideoZeroPipeline
from .pipeline_text_to_video_zero_sdxl import TextToVideoZeroSDXLPipeline

else:
import sys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from diffusers.pipelines.stable_diffusion import StableDiffusionPipeline, StableDiffusionSafetyChecker
from diffusers.schedulers import KarrasDiffusionSchedulers
from diffusers.utils import BaseOutput
from diffusers.utils.torch_utils import randn_tensor


def rearrange_0(tensor, f):
Expand Down Expand Up @@ -135,7 +136,7 @@ def __call__(self, attn, hidden_states, encoder_hidden_states=None, attention_ma

# Cross Frame Attention
if not is_cross_attention:
video_length = key.size()[0] // self.batch_size
video_length = max(1, key.size()[0] // self.batch_size)
first_frame_index = [0] * video_length

# rearrange keys to have batch and frames in the 1st and 2nd dims respectively
Expand Down Expand Up @@ -339,7 +340,7 @@ def forward_loop(self, x_t0, t0, t1, generator):
x_t1:
Forward process applied to x_t0 from time t0 to t1.
"""
eps = torch.randn(x_t0.size(), generator=generator, dtype=x_t0.dtype, device=x_t0.device)
eps = randn_tensor(x_t0.size(), generator=generator, dtype=x_t0.dtype, device=x_t0.device)
alpha_vec = torch.prod(self.scheduler.alphas[t0:t1])
x_t1 = torch.sqrt(alpha_vec) * x_t0 + torch.sqrt(1 - alpha_vec) * eps
return x_t1
Expand Down
Loading