Download exp_code/1_benchmark/Wan/inference_t2v.py from SuperCS/useful_code: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/datasets/SuperCS/useful_code/resolve/aa8ee3caa0e01f55ccefdb2f4bbc59ede129fc4e/exp_code/1_benchmark/Wan/inference_t2v.py
- Command line
-
hf download hf://datasets/SuperCS/useful_code@aa8ee3caa0e01f55ccefdb2f4bbc59ede129fc4e/exp_code/1_benchmark/Wan/inference_t2v.py
-
curl -L -o inference_t2v.py https://huggingface.co/datasets/SuperCS/useful_code/resolve/aa8ee3caa0e01f55ccefdb2f4bbc59ede129fc4e/exp_code/1_benchmark/Wan/inference_t2v.py
1.3 kB
| import torch | |
| from diffusers.utils import export_to_video | |
| from diffusers import AutoencoderKLWan, WanPipeline | |
| # Available models: Wan-AI/Wan2.1-T2V-14B-Diffusers, Wan-AI/Wan2.1-T2V-1.3B-Diffusers | |
| model_id = "/mnt/workspace/checkpoints/Wan-AI/Wan2.1-T2V-14B-Diffusers" | |
| vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32) | |
| pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16) | |
| pipe.to("cuda") | |
| prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window." | |
| negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards" | |
| output = pipe( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| height=480, | |
| width=832, | |
| num_frames=33, | |
| guidance_scale=5.0, | |
| ).frames[0] | |
| export_to_video(output, "output.mp4", fps=16) |