Skip to content

Commit 6e1b557

Browse files
committed
update example snippet
1 parent f0d286b commit 6e1b557

1 file changed

Lines changed: 31 additions & 15 deletions

File tree

src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video_framepack.py

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,41 @@
5353
Examples:
5454
```python
5555
>>> import torch
56-
>>> from diffusers import HunyuanVideoPipeline, HunyuanVideoTransformer3DModel
57-
>>> from diffusers.utils import export_to_video
56+
>>> from diffusers import HunyuanVideoFramepackPipeline, HunyuanVideoFramepackTransformer3DModel
57+
>>> from diffusers.utils import export_to_video, load_image
58+
>>> from transformers import SiglipImageProcessor, SiglipVisionModel
5859
59-
>>> model_id = "hunyuanvideo-community/HunyuanVideo"
60-
>>> transformer = HunyuanVideoTransformer3DModel.from_pretrained(
61-
... model_id, subfolder="transformer", torch_dtype=torch.bfloat16
60+
>>> transformer = HunyuanVideoFramepackTransformer3DModel.from_pretrained(
61+
... "lllyasviel/FramePackI2V_HY", torch_dtype=torch.bfloat16
62+
... )
63+
>>> feature_extractor = SiglipImageProcessor.from_pretrained(
64+
... "lllyasviel/flux_redux_bfl", subfolder="feature_extractor"
65+
... )
66+
>>> image_encoder = SiglipVisionModel.from_pretrained(
67+
... "lllyasviel/flux_redux_bfl", subfolder="image_encoder", torch_dtype=torch.float16
68+
... )
69+
>>> pipe = HunyuanVideoFramepackPipeline.from_pretrained(
70+
... "hunyuanvideo-community/HunyuanVideo",
71+
... transformer=transformer,
72+
... feature_extractor=feature_extractor,
73+
... image_encoder=image_encoder,
74+
... torch_dtype=torch.float16,
6275
... )
63-
>>> pipe = HunyuanVideoPipeline.from_pretrained(model_id, transformer=transformer, torch_dtype=torch.float16)
6476
>>> pipe.vae.enable_tiling()
6577
>>> pipe.to("cuda")
6678
79+
>>> image = load_image("inputs/penguin.png")
6780
>>> output = pipe(
68-
... prompt="A cat walks on the grass, realistic",
69-
... height=320,
70-
... width=512,
71-
... num_frames=61,
81+
... image=image,
82+
... prompt="A penguin dancing in the snow",
83+
... height=832,
84+
... width=480,
85+
... num_frames=91,
7286
... num_inference_steps=30,
87+
... guidance_scale=9.0,
88+
... generator=torch.Generator().manual_seed(0),
7389
... ).frames[0]
74-
>>> export_to_video(output, "output.mp4", fps=15)
90+
>>> export_to_video(output, "output.mp4", fps=30)
7591
```
7692
"""
7793

@@ -882,8 +898,8 @@ def __call__(
882898

883899
if history_video is None:
884900
if not output_type == "latent":
885-
current_video = real_history_latents.to(vae_dtype) / self.vae.config.scaling_factor
886-
history_video = self.vae.decode(current_video, return_dict=False)[0]
901+
current_latents = real_history_latents.to(vae_dtype) / self.vae.config.scaling_factor
902+
history_video = self.vae.decode(current_latents, return_dict=False)[0]
887903
else:
888904
history_video = [real_history_latents]
889905
else:
@@ -892,11 +908,11 @@ def __call__(
892908
(latent_window_size * 2 + 1) if is_last_section else (latent_window_size * 2)
893909
)
894910
overlapped_frames = (latent_window_size - 1) * self.vae_scale_factor_temporal + 1
895-
current_video = (
911+
current_latents = (
896912
real_history_latents[:, :, :section_latent_frames].to(vae_dtype)
897913
/ self.vae.config.scaling_factor
898914
)
899-
current_video = self.vae.decode(current_video, return_dict=False)[0]
915+
current_video = self.vae.decode(current_latents, return_dict=False)[0]
900916
history_video = self._soft_append(current_video, history_video, overlapped_frames)
901917
else:
902918
history_video.append(real_history_latents)

0 commit comments

Comments
 (0)