Views
No views yet
pip install git+https://github.com/huggingface/diffusers.git1import torch
2from diffusers.utils import export_to_video
3from diffusers import AutoencoderKLWan, WanPipeline
4from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
5
6model_id = "Wan-AI/Wan2.1-T2V-14B-Diffusers"
7vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
8pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
9pipe.scheduler = UniPCMultistepScheduler.from_config(
10 pipe.scheduler.config,
11 flow_shift=5.0
12)
13pipe.to("cuda")
14pipe.load_lora_weights("benjamin-paine/steamboat-willie-14b")
15pipe.enable_model_cpu_offload() # for low-vram environments
16
17prompt = "steamboat willie style, golden era animation, an anthropomorphic cat character wearing a hat removes it and performs a courteous bow"
18negative_prompt = "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
19output = pipe(
20 prompt=prompt,
21 negative_prompt=negative_prompt,
22 height=720,
23 width=1280,
24 num_frames=81,
25 guidance_scale=5.0,
26 num_inference_steps=32
27).frames[0]
28export_to_video(output, "output.mp4", fps=16)