Skip to content

Conversation

linoytsaban
Copy link
Collaborator

@linoytsaban linoytsaban commented May 13, 2025

example (both videos generated with the same params, top w/ lora loading, bottom w/o)
(input image is a white background to allow T2V LoRA to work properly):

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.load_lora_weights("linoyts/Hunyuan-LoRA", adapter_name="hunyuanvideo-lora")
pipe.set_adapters(["hunyuanvideo-lora"], [0.8])

pipe.vae.enable_tiling()
pipe.to("cuda")

image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/white_img.png")
output = pipe(
    image=image,
    prompt="flat color, no lineart, blending, negative space, a penguin dancing in the snow",
    height=832,
    width=480,
    num_frames=91,
    num_inference_steps=25,
    guidance_scale=10.0,
    generator=torch.Generator().manual_seed(0),
).frames[0]
export_to_video(output, "output.mp4", fps=30)
output-91.mp4
output-92.mp4

@linoytsaban linoytsaban changed the title [FramePack] small change to support Hunyuan LoRA Loading for FramePack [LoRA] small change to support Hunyuan LoRA Loading for FramePack May 13, 2025
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@a-r-r-o-w a-r-r-o-w left a comment

Choose a reason for hiding this comment

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

thanks!

@linoytsaban linoytsaban merged commit 8b99f7e into huggingface:main May 13, 2025
29 checks passed
@DN6 DN6 added the roadmap Add to current release roadmap label Jun 5, 2025
@DN6 DN6 moved this from In Progress to Done in Diffusers Roadmap 0.36 Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
roadmap Add to current release roadmap
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants