基于昇腾 Ascend NPU 的文本到人体动作生成模型适配仓库。
FloodDiffusionTiny 是 FloodDiffusion 系列的轻量化版本,专注于从自然语言描述生成连续人体运动序列。本仓库完成了该模型在华为昇腾 Ascend NPU 平台上的适配工作,支持通过文本描述驱动生成 263 维 HumanML3D 特征或 22 个关节点的三维坐标数据。
原始模型由 ShandaAI 团队基于 Diffusion Forcing 框架提出,本适配版本在保留原始模型能力的基础上,将推理后端从 CUDA 迁移至昇腾 NPU,实现了完整的服务化部署与推理验证。
| 组件 | 规格 |
|---|---|
| 操作系统 | Linux (aarch64) |
| NPU 型号 | Ascend 910B |
| NPU 驱动 | CANN 8.5.1 |
| PyTorch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| Python | 3.11.14 |
| 模型权重 | 36MB (model.safetensors) + 70MB (vae.safetensors) |
| 文本编码器 | google/umt5-base (2.3GB) |
# 单次推理
python3 inference.py --text "a person walking forward" --length 60
# 输出关节点坐标
python3 inference.py --text "a person waving hand" --length 40 --output-joints
# 保存结果到文件
python3 inference.py --text "a person jumping" --length 50 --save motion.npy# 启动 FastAPI 服务(默认端口 8006)
python3 service.py 8006
# 健康检查
curl http://localhost:8006/health
# 调用推理接口
curl -X POST http://localhost:8006/generate \
-H "Content-Type: application/json" \
-d '{"text": "a person walking forward", "length": 60, "num_denoise_steps": 20}'启动服务后执行以下命令确认服务正常运行:
# 1. 健康检查应返回 {"status":"ok","model_loaded":true}
curl http://localhost:8006/health
# 2. 简单的推理测试
curl -X POST http://localhost:8006/generate \
-H "Content-Type: application/json" \
-d '{"text": "a person walking", "length": 30, "num_denoise_steps": 10}'
# 3. 批量推理测试
curl -X POST http://localhost:8006/generate \
-H "Content-Type: application/json" \
-d '{"text": ["walk", "run"], "length": [30, 20]}'在 Ascend 910B NPU 上的实测性能数据:
| 推理参数 | 帧数 | 耗时 | 输出维度 |
|---|---|---|---|
| length=60, steps=20 | 237帧 | 12.5秒 | 237x263 |
| length=40, steps=20 | 157帧 | 8.1秒 | 157x263 |
| length=50, steps=20 | 197帧 | 10.1秒 | 197x263 |
NPU 显存占用约 238MB,运行过程中 NPU 温度稳定在 45°C 左右。
推理输出验证标准:
以 "a person walking forward"(length=60)为例,生成的 263 维特征前 8 维在前 3 帧的数值连续性好,表明运动平滑度符合预期。