Views
No views yet
pip install diffsynth1import torch
2from diffsynth import ModelManager, WanVideoPipeline, save_video, VideoData
3from modelscope import snapshot_download
4
5
6# Download models
7snapshot_download("Wan-AI/Wan2.1-T2V-1.3B", local_dir="models/Wan-AI/Wan2.1-T2V-1.3B")
8snapshot_download("DiffSynth-Studio/Wan2.1-1.3b-speedcontrol-v1", local_dir="models/DiffSynth-Studio/Wan2.1-1.3b-speedcontrol-v1")
9
10# Load models
11model_manager = ModelManager(device="cpu")
12model_manager.load_models(
13 [
14 "models/Wan-AI/Wan2.1-T2V-1.3B/diffusion_pytorch_model.safetensors",
15 "models/Wan-AI/Wan2.1-T2V-1.3B/models_t5_umt5-xxl-enc-bf16.pth",
16 "models/Wan-AI/Wan2.1-T2V-1.3B/Wan2.1_VAE.pth",
17 "models/DiffSynth-Studio/Wan2.1-1.3b-speedcontrol-v1/model.safetensors",
18 ],
19 torch_dtype=torch.bfloat16, # You can set `torch_dtype=torch.float8_e4m3fn` to enable FP8 quantization.
20)
21pipe = WanVideoPipeline.from_model_manager(model_manager, torch_dtype=torch.bfloat16, device="cuda")
22pipe.enable_vram_management(num_persistent_param_in_dit=None)
23
24# Text-to-video
25video = pipe(
26 prompt="Documentary photography style scene: a lively little dog rapidly running on a green grassy field. The dog has a brownish-yellow coat, upright ears, and an expression of focus and joy. Sunlight shines on its body, making its fur appear exceptionally soft and shiny. The background is an open grassland, occasionally dotted with a few wildflowers, with a faint view of blue sky and some white clouds in the distance. Strong sense of perspective captures the dynamic motion of the running dog and the vitality of the surrounding grass. Medium shot with a side-moving viewpoint.",
27 negative_prompt="vivid colors, overexposed, static, blurry details, subtitles, style, artwork, painting, frame, still, overall grayish, worst quality, low quality, JPEG compression artifacts, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn face, deformed, disfigured, malformed limbs, fused fingers, motionless frame, cluttered background, three legs, crowded background, walking backwards",
28 num_inference_steps=50,
29 seed=1, tiled=True,
30 motion_bucket_id=0
31)
32save_video(video, "video_slow.mp4", fps=15, quality=5)
33
34video = pipe(
35 prompt="Documentary photography style scene: a lively little dog rapidly running on a green grassy field. The dog has a brownish-yellow coat, upright ears, and an expression of focus and joy. Sunlight shines on its body, making its fur appear exceptionally soft and shiny. The background is an open grassland, occasionally dotted with a few wildflowers, with a faint view of blue sky and some white clouds in the distance. Strong sense of perspective captures the dynamic motion of the running dog and the vitality of the surrounding grass. Medium shot with a side-moving viewpoint.",
36 negative_prompt="vivid colors, overexposed, static, blurry details, subtitles, style, artwork, painting, frame, still, overall grayish, worst quality, low quality, JPEG compression artifacts, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn face, deformed, disfigured, malformed limbs, fused fingers, motionless frame, cluttered background, three legs, crowded background, walking backwards",
37 num_inference_steps=50,
38 seed=1, tiled=True,
39 motion_bucket_id=100
40)
41save_video(video, "video_fast.mp4", fps=15, quality=5)