FloodDiffusion: Tailored Diffusion Forcing for Streaming Motion Generation
本仓库是 ShandaAI/FloodDiffusion
(HF 重定向到 AlayaLab/FloodDiffusion)在 华为昇腾 Ascend910 NPU (torch_npu) 上的适配工程。
模型为 Latent Diffusion Forcing (WAN) 文本到人体动作生成模型: 给定动作描述文本,输出 HumanML3D 263 维动作特征序列(帧数 ≈ length × 4)。
ldf_deps/t5_umt5-xxl-enc-bf16/models_t5_umt5-xxl-enc-bf16.pth,约 11.3GB)cuda 设备调用(grep -rin cuda --include=*.py . 零命中)。
模型与输入均运行在 npu 设备,get_device() 内置 try-except 回退 CPU。ldf_models/tools/attention.py 已改写为
torch.nn.functional.scaled_dot_product_attention(带 padding mask),为该模型的默认注意力实现。rope_params/rope_apply 由 float64/complex128
改为 float32/complex64(精度足够,规避 NPU 算子限制)。npu:0 上运行;
若个别算子 NPU 不支持,自动对该冻结编码器做 CPU fallback,并把文本特征 .to(device) 回 NPU 后
再交给 LDF 扩散模型与 VAE(扩散模型与 VAE 始终在 npu:0)。./model_weights/ShandaAI/FloodDiffusion/,避免重复下载。huggingface-hub>=0.34,<1.0,
inference.py 内置版本修复块,自动选用兼容的 user-site huggingface_hub。pip install -i https://repo.huaweicloud.com/repository/pypi/simple/ \
lightning diffusers omegaconf ftfy numpy safetensors einops transformerspython3 download_weights.py ShandaAI/FloodDiffusion大文件(11.3GB UMT5-XXL
.pth)下载较慢,download_weights.py已缓存时自动跳过。
export ASCEND_RT_VISIBLE_DEVICES=0
python inference.py --input "a person walks forward" --length 60 --num_denoise_steps 10输出示例(263 维 HumanML3D 特征,帧数 ≈ length × 4):
{
"model": "ShandaAI/FloodDiffusion",
"device": "npu:0",
"text": "a person walks forward",
"length": 60,
"feature_shape": [237, 263],
"sample_rows": [[...], ...],
"stats": {"min": ..., "max": ..., "mean": ..., "std": ...}
}python inference.py --serve --port 8000 # http://0.0.0.0:8000GET /:带文本输入框的 HTML 页面POST /predict:接收 JSON {"text": "...", "length": 60} 或 multipart 表单,返回动作序列 JSONfrom transformers import AutoModel
model = AutoModel.from_pretrained(
"ShandaAI/FloodDiffusion",
trust_remote_code=True,
local_files_only=False,
)
motion = model("a person walking forward", length=60) # (~240, 263)@article{cai2025flooddiffusion,
title={FloodDiffusion: Tailored Diffusion Forcing for Streaming Motion Generation},
author={Yiyi Cai, Yuhan Wu, Kunhang Li, You Zhou, Bo Zheng, Haiyang Liu},
journal={arXiv preprint arXiv:2512.03520},
year={2025}
}