Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LoRA] Support original format loras for HunyuanVideo #10376

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

a-r-r-o-w
Copy link
Member

Fixes #10106 (comment)

Some LoRAs for testing:

import torch
from diffusers import HunyuanVideoPipeline, HunyuanVideoTransformer3DModel
from diffusers.utils import export_to_video

model_id = "hunyuanvideo-community/HunyuanVideo"
transformer = HunyuanVideoTransformer3DModel.from_pretrained(model_id, subfolder="transformer", torch_dtype=torch.bfloat16)
pipe = HunyuanVideoPipeline.from_pretrained(model_id, transformer=transformer, torch_dtype=torch.float16)
pipe.load_lora_weights("svjack/Genshin_Impact_XiangLing_Low_Res_HunyuanVideo_lora_early", weight_name="xiangling_ep1_lora.safetensors", adapter_name="hunyuan-lora")
pipe.set_adapters("hunyuan-lora", 0.8)
pipe.vae.enable_tiling()
pipe.to("cuda")

output = pipe(
    prompt=".....",
    height=320,
    width=512,
    num_frames=61,
    num_inference_steps=30,
    generator=torch.Generator().manual_seed(42),
).frames[0]
export_to_video(output, "output.mp4", fps=15)

cc @svjack Would you be able to give this a try?

@a-r-r-o-w a-r-r-o-w requested review from DN6 and sayakpaul December 25, 2024 10:02
@a-r-r-o-w
Copy link
Member Author

a-r-r-o-w commented Dec 25, 2024

@sayakpaul @DN6 Not comfortable adding integrations tests with any of the existing original-format loras on the Hub/CivitAI for HunyuanVideo. They are either Anime/NSFW/Person-related loras which we usually don't use for testing. I'll work on training a style lora over the next few days and convert it to original format for integration tests. Does that sound good?

@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

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Perfect! Okay to merge for me after an integration test!



def _convert_hunyuan_video_lora_to_diffusers(original_state_dict):
converted_state_dict = {k: original_state_dict.pop(k) for k in list(original_state_dict.keys())}
Copy link
Member

Choose a reason for hiding this comment

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

We usually add a check on original_state_dict if it's been emptied for converters like this. Do we wanna do that here?

if len(original_state_dict) > 0:

@nitinmukesh
Copy link

Subscribing to this PR

@yardenfren1996
Copy link

Hi, does Diffusers have a training script available for training HunyuanVideo LoRAs?

@sayakpaul
Copy link
Member

We do, thanks to @a-r-r-o-w 🐐
Check out https://github.com/a-r-r-o-w/finetrainers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add HunyuanVideo
5 participants