| 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( | |
| "/mnt/workspace/checkpoints/lllyasviel/FramePackI2V_HY", torch_dtype=torch.bfloat16 | |
| ) | |
| feature_extractor = SiglipImageProcessor.from_pretrained( | |
| "/mnt/workspace/checkpoints/lllyasviel/flux_redux_bfl", subfolder="feature_extractor" | |
| ) | |
| image_encoder = SiglipVisionModel.from_pretrained( | |
| "/mnt/workspace/checkpoints/lllyasviel/flux_redux_bfl", subfolder="image_encoder", torch_dtype=torch.float16 | |
| ) | |
| pipe = HunyuanVideoFramepackPipeline.from_pretrained( | |
| "/mnt/workspace/checkpoints/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("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), | |
| ).frames[0] | |
| export_to_video(output, "output.mp4", fps=30) |