mirror of
https://github.com/modelscope/DiffSynth-Studio.git
synced 2026-03-18 22:08:13 +00:00
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import torch
|
|
from diffsynth.utils.data import save_video
|
|
from diffsynth.pipelines.wan_video import WanVideoPipeline, ModelConfig
|
|
|
|
|
|
vram_config = {
|
|
"offload_dtype": "disk",
|
|
"offload_device": "disk",
|
|
"onload_dtype": torch.bfloat16,
|
|
"onload_device": "cpu",
|
|
"preparing_dtype": torch.bfloat16,
|
|
"preparing_device": "cuda",
|
|
"computation_dtype": torch.bfloat16,
|
|
"computation_device": "cuda",
|
|
}
|
|
pipe = WanVideoPipeline.from_pretrained(
|
|
torch_dtype=torch.bfloat16,
|
|
device="cuda",
|
|
model_configs=[
|
|
ModelConfig(model_id="krea/krea-realtime-video", origin_file_pattern="krea-realtime-video-14b.safetensors", **vram_config),
|
|
ModelConfig(model_id="Wan-AI/Wan2.1-T2V-14B", origin_file_pattern="models_t5_umt5-xxl-enc-bf16.pth", **vram_config),
|
|
ModelConfig(model_id="Wan-AI/Wan2.1-T2V-14B", origin_file_pattern="Wan2.1_VAE.pth", **vram_config),
|
|
],
|
|
tokenizer_config=ModelConfig(model_id="Wan-AI/Wan2.1-T2V-1.3B", origin_file_pattern="google/umt5-xxl/"),
|
|
vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
|
|
)
|
|
|
|
# Text-to-video
|
|
video = pipe(
|
|
prompt="a cat sitting on a boat",
|
|
num_inference_steps=6, num_frames=81,
|
|
seed=0, tiled=True,
|
|
cfg_scale=1,
|
|
sigma_shift=20,
|
|
)
|
|
save_video(video, "video_krea-realtime-video.mp4", fps=15, quality=5)
|