Diffusers documentation
Framepack
Framepack
Gói ngữ cảnh khung đầu vào trong các mô hình dự đoán khung tiếp theo cho việc tạo video của Lvmin Zhang và Maneesh Agrawala.
Chúng tôi giới thiệu một cấu trúc mạng nơ-ron, FramePack, để huấn luyện các mô hình dự đoán khung hình tiếp theo (hoặc phần khung hình tiếp theo) cho việc tạo video. FramePack nén các khung hình đầu vào để làm cho độ dài ngữ cảnh của transformer là một số cố định bất kể độ dài của video. Kết quả là, chúng tôi có thể xử lý một số lượng lớn các khung hình bằng cách sử dụng khuếch tán video với nút cổ chai tính toán tương tự như khuếch tán ảnh. Điều này cũng làm cho kích thước lô video trong quá trình huấn luyện cao hơn đáng kể (kích thước lô trở nên tương đương với huấn luyện khuếch tán ảnh). Chúng tôi cũng đề xuất một phương pháp lấy mẫu chống trôi dạt, tạo ra các khung hình theo thứ tự thời gian đảo ngược với các điểm cuối được thiết lập sớm để tránh thiên kiến phơi bày (sai số tích lũy qua các lần lặp). Cuối cùng, chúng tôi chỉ ra rằng các mô hình khuếch tán video hiện có có thể được tinh chỉnh với FramePack, và chất lượng hình ảnh của chúng có thể được cải thiện vì việc dự đoán khung hình tiếp theo hỗ trợ các trình lập lịch khuếch tán cân bằng hơn với các bước thời gian dịch chuyển dòng ít cực đoan hơn.
Hãy chắc chắn xem qua hướng dẫn về Schedulers để tìm hiểu cách khám phá sự đánh đổi giữa tốc độ và chất lượng của scheduler, và xem phần tái sử dụng các thành phần giữa các pipeline để tìm hiểu cách nạp các thành phần giống nhau vào nhiều pipeline một cách hiệu quả.
Các model khả dụng
| Tên mô hình | Mô tả |
|---|---|
- lllyasviel/FramePackI2V_HY | Được huấn luyện với chiến lược “inverted anti-drifting” như mô tả trong bài báo. Khi chạy pipeline, suy luận yêu cầu đặt sampling_type="inverted_anti_drifting". |
- lllyasviel/FramePack_F1_I2V_HY_20250503 | Được huấn luyện với một chiến lược chống trôi mới, nhưng suy luận được thực hiện theo chiến lược “vanilla” như mô tả trong bài báo. Suy luận yêu cầu đặt sampling_type="vanilla" khi chạy pipeline. |
Cách sử dụng
Xem tài liệu pipeline để biết các ví dụ sử dụng cơ bản. Phần tiếp theo chứa các ví dụ về offloading, các phương pháp lấy mẫu khác nhau, lượng tử hóa và nhiều hơn nữa.
Khung đầu và khung cuối thành video
Ví dụ sau cho thấy cách sử dụng Framepack với các điều khiển ảnh bắt đầu và kết thúc, sử dụng mô hình lấy mẫu chống trôi ngược.
import torch
from diffusers import HunyuanVideoFramepackPipeline, HunyuanVideoFramepackTransformer3DModel
from diffusers.utils import export_to_video, load_image
from transformers import SiglipImageProcessor, SiglipVisionModel
transformer = HunyuanVideoFramepackTransformer3DModel.from_pretrained(
"lllyasviel/FramePackI2V_HY", dtype=torch.bfloat16
)
feature_extractor = SiglipImageProcessor.from_pretrained(
"lllyasviel/flux_redux_bfl", subfolder="feature_extractor"
)
image_encoder = SiglipVisionModel.from_pretrained(
"lllyasviel/flux_redux_bfl", subfolder="image_encoder", dtype=torch.float16
)
pipe = HunyuanVideoFramepackPipeline.from_pretrained(
"hunyuanvideo-community/HunyuanVideo",
transformer=transformer,
feature_extractor=feature_extractor,
image_encoder=image_encoder,
dtype=torch.float16,
)
# Enable memory optimizations
pipe.enable_model_cpu_offload()
pipe.vae.enable_tiling()
prompt = "CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird's feathers are delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, low-angle perspective."
first_image = load_image(
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_first_frame.png"
)
last_image = load_image(
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_last_frame.png"
)
output = pipe(
image=first_image,
last_image=last_image,
prompt=prompt,
height=512,
width=512,
num_frames=91,
num_inference_steps=30,
guidance_scale=9.0,
generator=torch.Generator().manual_seed(0),
sampling_type="inverted_anti_drifting",
).frames[0]
export_to_video(output, "output.mp4", fps=30)Mẫu hóa thông thường
Ví dụ sau cho thấy cách sử dụng Framepack với mô hình F1 được huấn luyện bằng phương pháp lấy mẫu thuần túy nhưng áp dụng cách tiếp cận điều chỉnh mới để chống trôi.
import torch
from diffusers import HunyuanVideoFramepackPipeline, HunyuanVideoFramepackTransformer3DModel
from diffusers.utils import export_to_video, load_image
from transformers import SiglipImageProcessor, SiglipVisionModel
transformer = HunyuanVideoFramepackTransformer3DModel.from_pretrained(
"lllyasviel/FramePack_F1_I2V_HY_20250503", dtype=torch.bfloat16
)
feature_extractor = SiglipImageProcessor.from_pretrained(
"lllyasviel/flux_redux_bfl", subfolder="feature_extractor"
)
image_encoder = SiglipVisionModel.from_pretrained(
"lllyasviel/flux_redux_bfl", subfolder="image_encoder", dtype=torch.float16
)
pipe = HunyuanVideoFramepackPipeline.from_pretrained(
"hunyuanvideo-community/HunyuanVideo",
transformer=transformer,
feature_extractor=feature_extractor,
image_encoder=image_encoder,
dtype=torch.float16,
)
# Enable memory optimizations
pipe.enable_model_cpu_offload()
pipe.vae.enable_tiling()
image = load_image(
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/penguin.png"
)
output = pipe(
image=image,
prompt="A penguin dancing in the snow",
height=832,
width=480,
num_frames=91,
num_inference_steps=30,
guidance_scale=9.0,
generator=torch.Generator().manual_seed(0),
sampling_type="vanilla",
).frames[0]
export_to_video(output, "output.mp4", fps=30)Tải xuống nhóm
Group offloading (apply_group_offloading()) cung cấp các tối ưu hóa bộ nhớ mạnh mẽ để offload các phần bên trong của bất kỳ model nào sang CPU, có thể không gây thêm chi phí nào cho thời gian generation. Nếu bạn có VRAM rất thấp, cách tiếp cận này có thể phù hợp với bạn tùy thuộc vào lượng RAM CPU khả dụng.
import torch
from diffusers import HunyuanVideoFramepackPipeline, HunyuanVideoFramepackTransformer3DModel
from diffusers.hooks import apply_group_offloading
from diffusers.utils import export_to_video, load_image
from transformers import SiglipImageProcessor, SiglipVisionModel
transformer = HunyuanVideoFramepackTransformer3DModel.from_pretrained(
"lllyasviel/FramePack_F1_I2V_HY_20250503", dtype=torch.bfloat16
)
feature_extractor = SiglipImageProcessor.from_pretrained(
"lllyasviel/flux_redux_bfl", subfolder="feature_extractor"
)
image_encoder = SiglipVisionModel.from_pretrained(
"lllyasviel/flux_redux_bfl", subfolder="image_encoder", dtype=torch.float16
)
pipe = HunyuanVideoFramepackPipeline.from_pretrained(
"hunyuanvideo-community/HunyuanVideo",
transformer=transformer,
feature_extractor=feature_extractor,
image_encoder=image_encoder,
dtype=torch.float16,
)
# Enable group offloading
onload_device = torch.device("cuda")
offload_device = torch.device("cpu")
list(map(
lambda x: apply_group_offloading(x, onload_device, offload_device, offload_type="leaf_level", use_stream=True, low_cpu_mem_usage=True),
[pipe.text_encoder, pipe.text_encoder_2, pipe.transformer]
))
pipe.image_encoder.to(onload_device)
pipe.vae.to(onload_device)
pipe.vae.enable_tiling()
image = load_image(
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/penguin.png"
)
output = pipe(
image=image,
prompt="A penguin dancing in the snow",
height=832,
width=480,
num_frames=91,
num_inference_steps=30,
guidance_scale=9.0,
generator=torch.Generator().manual_seed(0),
sampling_type="vanilla",
).frames[0]
print(f"Max memory: {torch.cuda.max_memory_allocated() / 1024**3:.3f} GB")
export_to_video(output, "output.mp4", fps=30)HunyuanVideoFramepackPipeline
lớp diffusers.HunyuanVideoFramepackPipeline
< source >( text_encoder: LlamaModeltokenizer: LlamaTokenizertransformer: HunyuanVideoFramepackTransformer3DModelvae: AutoencoderKLHunyuanVideoscheduler: FlowMatchEulerDiscreteSchedulertext_encoder_2: CLIPTextModeltokenizer_2: CLIPTokenizerimage_encoder: SiglipVisionModelfeature_extractor: SiglipImageProcessorPil )
Tham số
- text_encoder (
LlamaModel) — Llava Llama3-8B. - tokenizer (
LlamaTokenizer) — Tokenizer từ Llava Llama3-8B. - transformer (HunyuanVideoTransformer3DModel) — Transformer có điều kiện để khử nhiễu các latents ảnh đã mã hóa.
- scheduler (FlowMatchEulerDiscreteScheduler) —
Một scheduler được sử dụng kết hợp với
transformerđể khử nhiễu các latents ảnh đã được mã hóa. - vae (AutoencoderKLHunyuanVideo) — Mô hình Variational Auto-Encoder (VAE) để mã hóa và giải mã video sang và từ các biểu diễn ẩn (latent representations).
- text_encoder_2 (
CLIPTextModel) — CLIP, cụ thể là biến thể clip-vit-large-patch14. - tokenizer_2 (
CLIPTokenizer) — Tokenizer của lớp CLIPTokenizer.
Pipeline để tạo video từ văn bản sử dụng HunyuanVideo.
Mô hình này kế thừa từ DiffusionPipeline. Xem tài liệu của lớp cha để biết các phương thức chung được triển khai cho tất cả các pipeline (tải xuống, lưu, chạy trên một thiết bị cụ thể, v.v.).
__call__
< source >( image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]last_image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = Noneprompt: str | list[str] = Noneprompt_2: str | list[str] = Nonenegative_prompt: str | list[str] = Nonenegative_prompt_2: str | list[str] = Noneheight: int = 720width: int = 1280num_frames: int = 129latent_window_size: int = 9num_inference_steps: int = 50sigmas: list = Nonetrue_cfg_scale: float = 1.0guidance_scale: float = 6.0num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Noneimage_latents: typing.Optional[torch.Tensor] = Nonelast_image_latents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Nonepooled_prompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_attention_mask: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_pooled_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_attention_mask: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'pil'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list = ['latents']prompt_template: dict = {'template': '<|start_header_id|>system<|end_header_id|>\n\nDescribe the video by detailing the following aspects: 1. The main content and theme of the video.2. The color, shape, size, texture, quantity, text, and spatial relationships of the objects.3. Actions, events, behaviors temporal relationships, physical movement changes of the objects.4. background environment, light, style and atmosphere.5. camera angles, movements, and transitions used in the video:<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n{}<|eot_id|>', 'crop_start': 95}max_sequence_length: int = 256sampling_type: FramepackSamplingType = <FramepackSamplingType.INVERTED_ANTI_DRIFTING: 'inverted_anti_drifting'> ) → ~HunyuanVideoFramepackPipelineOutput or tuple
Tham số
- image (
PIL.Image.Imagehoặcnp.ndarrayhoặctorch.Tensor) — Hình ảnh được sử dụng làm điểm khởi đầu cho việc tạo video. - last_image (
PIL.Image.Imagehoặcnp.ndarrayhoặctorch.Tensor, tùy chọn) — Hình ảnh cuối cùng tùy chọn được sử dụng làm điểm kết thúc cho việc tạo video. Điều này hữu ích để tạo các chuyển cảnh giữa hai hình ảnh. - prompt (
strhoặclist[str], tùy chọn) — Prompt hoặc các prompt để định hướng việc tạo ảnh. Nếu không được định nghĩa, bạn phải truyềnprompt_embedsthay thế. - prompt_2 (
strhoặclist[str], tùy chọn) — Prompt hoặc các prompt sẽ được gửi đếntokenizer_2vàtext_encoder_2. Nếu không được định nghĩa,promptsẽ được sử dụng thay thế. - negative_prompt (
strhoặclist[str], tùy chọn) — Prompt hoặc các prompt không dùng để định hướng việc tạo ảnh. Nếu không được định nghĩa, cần truyềnnegative_prompt_embedsthay thế. Bỏ qua khi không sử dụng guidance (tức là bị bỏ qua nếutrue_cfg_scalekhông lớn hơn1). - negative_prompt_2 (
strhoặclist[str], tùy chọn) — Prompt hoặc các prompt không dùng để định hướng tạo ảnh, sẽ được gửi đếntokenizer_2vàtext_encoder_2. Nếu không được định nghĩa,negative_promptsẽ được sử dụng cho tất cả các text-encoder. - height (
int, mặc định là720) — Chiều cao của hình ảnh được tạo ra, tính bằng pixel. - width (
int, mặc định là1280) — Chiều rộng của hình ảnh được tạo ra, tính bằng pixel. - num_frames (
int, mặc định là129) — Số lượng khung hình trong video được tạo ra. - latent_window_size (
int, mặc định là9) — Số lượng khung latent được tạo ra cho mỗi cửa sổ lấy mẫu Framepack. - num_inference_steps (
int, mặc định là50) — Số bước khử nhiễu. Số bước khử nhiễu nhiều hơn thường dẫn đến hình ảnh có chất lượng cao hơn, với cái giá là suy luận chậm hơn. - sigmas (
list[float], tùy chọn) — Các sigma tùy chỉnh để sử dụng cho quá trình khử nhiễu với các trình lập lịch hỗ trợ đối sốsigmastrong phương thứcset_timestepscủa chúng. Nếu không được định nghĩa, hành vi mặc định khinum_inference_stepsđược truyền sẽ được sử dụng. - true_cfg_scale (
float, tùy chọn, mặc định là 1.0) — Khi > 1.0 và cónegative_promptđược cung cấp, sẽ kích hoạt true classifier-free guidance. - guidance_scale (
float, mặc định là6.0) — Thang độ dẫn hướng như được định nghĩa trong Classifier-Free Diffusion Guidance.guidance_scaleđược định nghĩa làwcủa phương trình 2. trong Imagen Paper. Thang độ dẫn hướng được kích hoạt bằng cách đặtguidance_scale > 1. Thang độ dẫn hướng cao hơn khuyến khích tạo ra các hình ảnh gắn kết chặt chẽ vớipromptvăn bản, thường phải đánh đổi bằng chất lượng hình ảnh thấp hơn. Lưu ý rằng mô hình HunyuanVideo duy nhất có sẵn là mô hình CFG-distilled, điều này có nghĩa là việc dẫn hướng truyền thống giữa latent không điều kiện và latent có điều kiện không được áp dụng. - num_videos_per_prompt (
int, tùy chọn, mặc định là 1) — Số lượng hình ảnh cần tạo cho mỗi prompt. - generator (
torch.Generatorhoặclist[torch.Generator], tùy chọn) — Mộttorch.Generatorđể làm cho quá trình sinh ra kết quả xác định. - image_latents (
torch.Tensor, tùy chọn) — Các latents của ảnh đã được mã hóa trước. Nếu không được cung cấp, ảnh sẽ được mã hóa bằng VAE. - last_image_latents (
torch.Tensor, tùy chọn) — Latents của ảnh cuối cùng đã được mã hóa trước. Nếu không được cung cấp, ảnh cuối cùng sẽ được mã hóa bằng VAE. - prompt_embeds (
torch.Tensor, tùy chọn) — Các embedding văn bản đã được tạo trước. Có thể dùng để dễ dàng điều chỉnh đầu vào văn bản (trọng số prompt). Nếu không được cung cấp, các embedding văn bản sẽ được tạo từ đối số đầu vàoprompt. - pooled_prompt_embeds (
torch.FloatTensor, tùy chọn) — Các embedding văn bản đã được gộp (pooled) sẵn. Có thể dùng để dễ dàng điều chỉnh đầu vào văn bản, vd. trọng số prompt. Nếu không được cung cấp, các embedding văn bản đã gộp sẽ được tạo từ đối số đầu vàoprompt. - negative_prompt_embeds (
torch.FloatTensor, tùy chọn) — Các embedding văn bản âm đã được tạo trước. Có thể dùng để dễ dàng điều chỉnh đầu vào văn bản, vd. trọng số prompt. Nếu không được cung cấp, negative_prompt_embeds sẽ được tạo từ đối số đầu vàonegative_prompt. - negative_pooled_prompt_embeds (
torch.FloatTensor, tùy chọn) — Các embedding văn bản pooled âm đã được tạo trước. Có thể dùng để dễ dàng điều chỉnh đầu vào văn bản, vd. trọng số prompt. Nếu không được cung cấp, pooled negative_prompt_embeds sẽ được tạo từ đối số đầu vàonegative_prompt. - prompt_attention_mask (
torch.Tensor, tùy chọn) — Mặt nạ chú ý choprompt_embeds. Bắt buộc khiprompt_embedsđược truyền trực tiếp. - negative_prompt_attention_mask (
torch.Tensor, tùy chọn) — Mặt nạ chú ý (attention mask) chonegative_prompt_embeds. Bắt buộc khinegative_prompt_embedsđược truyền trực tiếp. - output_type (
str, tùy chọn, mặc định là"pil") — Định dạng đầu ra của hình ảnh được tạo ra. Chọn giữaPIL.Imagehoặcnp.array. - return_dict (
bool, tùy chọn, mặc định làTrue) — Có nên trả về mộtHunyuanVideoFramepackPipelineOutputthay vì một tuple thông thường hay không. - attention_kwargs (
dict, tùy chọn) — Một từ điển kwargs, nếu được chỉ định, sẽ được truyền đếnAttentionProcessornhư đã định nghĩa dướiself.processortrong diffusers.models.attention_processor. - prompt_template (
dict, tùy chọn) — Mẫu được sử dụng để định dạng prompt trước khi mã hóa. Mặc định là mẫu mặc định của model. - max_sequence_length (
int, tùy chọn, mặc định là 256) — Chiều dài tối đa của chuỗi được sử dụng cho trình mã hóa prompt. - sampling_type (
FramepackSamplingType, không bắt buộc) — Chiến lược lấy mẫu Framepack được sử dụng khi lặp qua các cửa sổ latent. - callback_on_step_end (
Callable,PipelineCallback,MultiPipelineCallbacks, tùy chọn) — Một hàm hoặc một lớp con củaPipelineCallbackhoặcMultiPipelineCallbacksđược gọi vào cuối mỗi bước khử nhiễu trong quá trình suy luận, với các đối số sau:callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict).callback_kwargssẽ bao gồm một danh sách tất cả các tensor như được chỉ định bởicallback_on_step_end_tensor_inputs. - callback_on_step_end_tensor_inputs (
list, optional) — Danh sách các tensor đầu vào cho hàmcallback_on_step_end. Các tensor được chỉ định trong danh sách sẽ được truyền dưới dạng tham sốcallback_kwargs. Bạn chỉ có thể bao gồm các biến được liệt kê trong thuộc tính._callback_tensor_inputscủa lớp pipeline của bạn.
Trả về
~HunyuanVideoFramepackPipelineOutput hoặc tuple
Nếu return_dict là True, HunyuanVideoFramepackPipelineOutput sẽ được trả về, ngược lại một tuple sẽ được trả về trong đó phần tử đầu tiên là một danh sách chứa các hình ảnh được tạo ra và phần tử thứ hai là một danh sách các bool cho biết hình ảnh được tạo ra tương ứng có chứa nội dung “not-safe-for-work” (nsfw) hay không.
Hàm gọi call của pipeline để tạo nội dung.
Ví dụ:
Hình ảnh sang Video
>>> import torch
>>> from diffusers import HunyuanVideoFramepackPipeline, HunyuanVideoFramepackTransformer3DModel
>>> from diffusers.utils import export_to_video, load_image
>>> from transformers import SiglipImageProcessor, SiglipVisionModel
>>> transformer = HunyuanVideoFramepackTransformer3DModel.from_pretrained(
... "lllyasviel/FramePackI2V_HY", torch_dtype=torch.bfloat16
... )
>>> feature_extractor = SiglipImageProcessor.from_pretrained(
... "lllyasviel/flux_redux_bfl", subfolder="feature_extractor"
... )
>>> image_encoder = SiglipVisionModel.from_pretrained(
... "lllyasviel/flux_redux_bfl", subfolder="image_encoder", torch_dtype=torch.float16
... )
>>> pipe = HunyuanVideoFramepackPipeline.from_pretrained(
... "hunyuanvideo-community/HunyuanVideo",
... transformer=transformer,
... feature_extractor=feature_extractor,
... image_encoder=image_encoder,
... torch_dtype=torch.float16,
... )
>>> pipe.vae.enable_tiling()
>>> pipe.to("cuda")
>>> image = load_image(
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/penguin.png"
... )
>>> output = pipe(
... image=image,
... prompt="A penguin dancing in the snow",
... height=832,
... width=480,
... num_frames=91,
... num_inference_steps=30,
... guidance_scale=9.0,
... generator=torch.Generator().manual_seed(0),
... sampling_type="inverted_anti_drifting",
... ).frames[0]
>>> export_to_video(output, "output.mp4", fps=30)Hình ảnh đầu và cuối thành video
>>> import torch
>>> from diffusers import HunyuanVideoFramepackPipeline, HunyuanVideoFramepackTransformer3DModel
>>> from diffusers.utils import export_to_video, load_image
>>> from transformers import SiglipImageProcessor, SiglipVisionModel
>>> transformer = HunyuanVideoFramepackTransformer3DModel.from_pretrained(
... "lllyasviel/FramePackI2V_HY", torch_dtype=torch.bfloat16
... )
>>> feature_extractor = SiglipImageProcessor.from_pretrained(
... "lllyasviel/flux_redux_bfl", subfolder="feature_extractor"
... )
>>> image_encoder = SiglipVisionModel.from_pretrained(
... "lllyasviel/flux_redux_bfl", subfolder="image_encoder", torch_dtype=torch.float16
... )
>>> pipe = HunyuanVideoFramepackPipeline.from_pretrained(
... "hunyuanvideo-community/HunyuanVideo",
... transformer=transformer,
... feature_extractor=feature_extractor,
... image_encoder=image_encoder,
... torch_dtype=torch.float16,
... )
>>> pipe.to("cuda")
>>> prompt = "CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird's feathers are delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, low-angle perspective."
>>> first_image = load_image(
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_first_frame.png"
... )
>>> last_image = load_image(
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_last_frame.png"
... )
>>> output = pipe(
... image=first_image,
... last_image=last_image,
... prompt=prompt,
... height=512,
... width=512,
... num_frames=91,
... num_inference_steps=30,
... guidance_scale=9.0,
... generator=torch.Generator().manual_seed(0),
... sampling_type="inverted_anti_drifting",
... ).frames[0]
>>> export_to_video(output, "output.mp4", fps=30)HunyuanVideoPipelineOutput
lớp diffusers.pipelines.hunyuan_video.pipeline_output.HunyuanVideoPipelineOutput
< source >( frames: Tensor )
Tham số
- frames (
torch.Tensor,np.ndarray, hoặc list[list[PIL.Image.Image]]) — danh sách các đầu ra video - Có thể là một danh sách lồng nhau có độ dàibatch_size,trong đó mỗi danh sách con chứa các chuỗi hình ảnh PIL đã khử nhiễu có độ dàinum_frames.Nó cũng có thể là một mảng NumPy hoặc tensor Torch có hình dạng(batch_size, num_frames, channels, height, width).
Lớp đầu ra cho các pipeline của HunyuanVideo.