Views
No views yet
pip install git+https://github.com/ollanoinc/hyvideo.git1import os
2from hyvideo.diffusion.pipelines.pipeline_hunyuan_video import HunyuanVideoPipeline
3from hyvideo.modules.models import HYVideoDiffusionTransformer
4from hyvideo.vae.autoencoder_kl_causal_3d import AutoencoderKLCausal3D
5import diffusers.pipelines
6
7from types import ModuleType
8def set_nested_attr(current, path, value):
9 parts = path.split('.')
10 for part in parts[:-1]:
11 if not hasattr(current, part):
12 setattr(current, part, ModuleType(part))
13 current = getattr(current, part)
14 setattr(current, parts[-1], value)
15
16set_nested_attr(diffusers.pipelines, 'hyvideo.HunyuanVideoPipeline', HunyuanVideoPipeline)
17set_nested_attr(diffusers.pipelines, 'hyvideo.HYVideoDiffusionTransformer', HYVideoDiffusionTransformer)
18set_nested_attr(diffusers.pipelines, 'hyvideo.AutoencoderKLCausal3D', AutoencoderKLCausal3D)
19
20os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
21
22pipe = HunyuanVideoPipeline.from_pretrained(
23 "magespace/hyvideo-diffusers",
24 torch_dtype=torch.bfloat16
25).to("cuda")
26pipe.vae.enable_tiling()1prompt = "Close-up, A little girl wearing a red hoodie in winter strikes a match. The sky is dark, there is a layer of snow on the ground, and it is still snowing lightly. The flame of the match flickers, illuminating the girl's face intermittently."
2
3result = pipe(prompt)1import PIL.Image
2from diffusers.utils import export_to_video
3
4output = result.videos[0].permute(1, 2, 3, 0).detach().cpu().numpy()
5output = (output * 255).clip(0, 255).astype("uint8")
6output = [PIL.Image.fromarray(x) for x in output]
7
8export_to_video(output, "output.mp4", fps=24)transformer with torch.compile. Additionally, increasing shift in the scheduler can allow for lower step values as shown in the original paper.