⏱ ~33 min
里程碑
⭐ 为何重要

motion diffusion 的开山之作:把 DDPM 引入人体动作生成,配 classifier-free 文本条件与 transformer 骨架,将动作生成从 GAN/VAE 时代推进到 diffusion 时代。它成为后续 PhysDiff、PriorMDM、MoMask、GMD 等几乎所有 motion diffusion 工作的通用 baseline。在 action_gen 谱系里它是生成式动作建模的里程碑与分水岭。

建立在
  • MotionDiffuse
  • DDPM
数据集HumanML3D, KIT-ML
输入模态language

MDM: Human Motion Diffusion Model

作者 / 机构:Guy Tevet, Sigal Raab, Brian Gordon, Yonatan Shafir, Daniel Cohen-Or, Amit H. Bermano / Tel Aviv University
发表:ICLR 2023(2022.09 arXiv 首发,arXiv:2209.14916v2)
arxiv2209.14916 · 代码:https://github.com/GuyTevet/motion-diffusion-model · 项目页:https://guytevet.github.io/mdm-page/
在线索中的位置:属于 [T08 · Action Generation with Physics] 的起点 / 把 diffusion 搬进动作域的开山之作;与 T05(Diffusion Policy)同源技术、不同目标——T05 用 diffusion 生成控制 action,MDM 用 diffusion 生成 kinematic motion 序列。
一句话定位:第一个把 diffusion model 成功用于人体动作生成(text-to-motion / action-to-motion / unconditional)的工作。架构上是 transformer encoder-only(不是 U-Net),预测样本 $\hat x_0$ 而非噪声 $\epsilon$(这样才能用 geometric losses),用 classifier-free guidance 训条件 + 无条件同一模型,单 RTX 2080 Ti 训 3 天就在 HumanML3D / KIT 上达 SOTA


动机

到 2022 年中,人体动作生成(human motion generation)的主流是 VAE 路线:TEMOS、T2M 把文本编码到 latent normal distribution,MotionCLIP 借 CLIP 的 text-image shared latent。VAE 路线的硬伤:normal latent 假设导致学到的分布是「一对一映射」或被压成单峰,无法表达「同一文本对应多种动作」的 many-to-many(比如「踢」可以是足球踢也可以是空手道踢,描述同一踢的动作也可以有上千万种说法)。

Diffusion model 在图像上已经证明能 express many-to-many 分布且不预设目标分布形状,是文本到动作的天然候选。但把 diffusion 搬到动作域有两个具体困难:

  1. 资源贵:图像 diffusion 用 U-Net + 大算力,直接套到动作上太重。
  2. 难加 geometric loss:动作生成的 SOTA 都靠 geometric losses(位置/速度/foot contact),但标准 DDPM 预测的是噪声 $\epsilon$,geometric loss 没法直接套到噪声上。

MDM 要回答:能否设计一个 lightweight、能用 geometric losses、支持多任务条件化的 motion diffusion 模型?


方法核心:transformer + 预测 $\hat x_0$ + classifier-free

一、为什么不用 U-Net:transformer encoder-only

动作数据和图像数据结构不同:图像是 2D 空间网格(适合 U-Net 卷积的下/上采样),动作是「N 帧 × J 关节 × D 维表示」的时间序列 + 非空间关节集合。MDM 用 transformer encoder-only(Fig. 2),原因:

  • transformer 天生 temporal-aware,能处理任意长度序列。
  • 已有 motion generation 工作(Actor, MotionTransformer 等)已证明 transformer 在动作域比 RNN/CNN 强。
  • encoder-only 比 encoder-decoder 还轻。

模型结构(Fig. 2 左):

  • 输入:noised motion $x_t^{1:N}$(N 帧,每帧 $x^i \in \mathbb{R}^{J \times D}$,J 是关节数,D 是每关节表示维度,可以是 rotation、position 或两者)。
  • 把 time step $t$ 和 condition code $c$ 各自经 FFN 投影到 transformer dim,相加成单个 token $z_t^k$。
  • 每帧 $x_t^i$ 线性投影到 transformer dim + 标准 positional embedding
  • $z_t^k$ 和投影后的帧 token 一起喂 encoder。
  • 输出:丢掉第一个 token($z_t^k$ 对应的),其余投影回 motion 维度得到 $\hat x_0^{1:N}$。

整个模型 8 层 transformer、latent dim 512、batch 64,比图像 diffusion 小一两个数量级(论文原文只说 "order of magnitude smaller than images")。

二、关键设计选择:预测 $\hat x_0$ 而不是 $\epsilon$(geometric losses 的前提)

标准 DDPM [Ho et al. 2020] 预测噪声 $\epsilon$,loss 是 $\|\epsilon - \epsilon_\theta\|^2$。MDM 跟着 Ramesh et al. 2022 (DALL-E 2) 改成直接预测 clean sample $\hat x_0 = G(x_t, t, c)$,simple loss:

$$\mathcal{L}_\text{simple} = \mathbb{E}_{x_0 \sim q(x_0|c), t \sim [1,T]} \|x_0 - G(x_t, t, c)\|_2^2$$

为什么这个改动关键:因为 $G$ 直接输出 motion $\hat x_0$,所以可以在 $\hat x_0$ 上加 geometric loss——而 $\epsilon$ 上加不了(噪声没有「关节位置」「足触地」这些物理意义)。这是 MDM 把 motion generation 文献积累的 geometric losses 搬进 diffusion 的关键 trick。

三个 geometric losses

  • Position loss(Eq. 3):$\mathcal{L}_\text{pos} = \frac{1}{N}\sum_i \|FK(x_0^i) - FK(\hat x_0^i)\|^2$,$FK$ 是 forward kinematics。当预测 joint rotation 时用,把旋转转成位置再比(位置比旋转对感知更友好)。
  • Foot contact loss(Eq. 4):$\mathcal{L}_\text{foot} = \frac{1}{N-1}\sum_i \|(FK(\hat x_0^{i+1}) - FK(\hat x_0^i)) \cdot f_i\|^2$,$f_i \in \{0,1\}^J$ 是足触地 mask。抑制 foot sliding(足触地时速度归零)。
  • Velocity loss(Eq. 5):$\mathcal{L}_\text{vel} = \frac{1}{N-1}\sum_i \|(x_0^{i+1} - x_0^i) - (\hat x_0^{i+1} - \hat x_0^i)\|^2$,防 jitter。

总 loss(Eq. 6):$\mathcal{L} = \mathcal{L}_\text{simple} + \lambda_\text{pos}\mathcal{L}_\text{pos} + \lambda_\text{vel}\mathcal{L}_\text{vel} + \lambda_\text{foot}\mathcal{L}_\text{foot}$。

细节:HumanML3D 表示里已经显式包含 joint positions 和 foot contact labels,所以 text-to-motion 实验里不用 geometric losses(数据已含这些信号);只在 action-to-motion 用 rotation 表示时才用。

三、Classifier-free guidance:同模型同时学条件 + 无条件

训练时按 10% 概率把 condition $c$ 置空 $\emptyset$,让 $G(x_t, t, \emptyset)$ 近似无条件分布 $p(x_0)$。采样时按 Eq. 7 做条件 + 无条件差值的外推

$$G_s(x_t, t, c) = G(x_t, t, \emptyset) + s \cdot (G(x_t, t, c) - G(x_t, t, \emptyset))$$

$s=1$ 是纯条件采样,$s<1$ 偏多样性,$s>1$ 外推偏 fidelity。论文实测 $s=2.5$ 是 diversity-fidelity sweet spot(Fig. 4)。

text-to-motion 用 frozen CLIP-ViT-B/32 文本编码器把 prompt 转成 $c$;action-to-motion 用每类一个 learned embedding。CLIP 是冻结的,MDM 不训 CLIP

四、采样和编辑

采样(Fig. 2 右):T=1000 步,cosine noise schedule。每步 $t$ 预测 $\hat x_0 = G(x_t, t, c)$,按 DDPM 把它「重新加噪」回 $x_{t-1}$,迭代直到 $x_0$。

编辑(无训练,只改采样):用 diffusion inpainting 思路。给定一段 motion 的子集(时间前缀+后缀做 in-betweening,或部分身体关节做 body part editing),每个采样步用输入子集覆写 $\hat x_0$ 对应维度,让生成结果保留输入、补全缺失。可以带 condition $c$ 也可以无条件($c=\emptyset$)。


实验结果

三个任务:text-to-motion、action-to-motion、unconditional generation。

Text-to-Motion(HumanML3D + KIT):MDM 在 FID、Diversity、MultiModality 上达 SOTA,R-precision / Multimodal-Dist 也接近 SOTA。31 用户参与、基于 KIT 测试集的 side-by-side 用户研究里,MDM 大多数时候胜过基线(JL2P / TEMOS / T2M),42.3% 的情况下用户偏好 MDM 生成结果甚至超过 ground truth——说明 MDM 在「自然度」上已经接近真实 MoCap

Action-to-Motion(HumanAct12 + UESTC):MDM 超过专门为 action-to-motion 设计的 SOTA(Guo 2020, Petrovich 2021),即便后者是 task-specific。

架构 ablation(Table 1,HumanML3D):测了 4 个 backbone——(1) transformer encoder-only(默认)、(2) transformer decoder + cross-attention 注入 $z_t^k$、(3) decoder + input token 双注入、(4) GRU。结论:diffusion 框架对 backbone 不敏感(架构差异 < 任务差异),但 encoder-only 是最简单且最稳的选择。

训练成本:单 RTX 2080 Ti(消费级),约 3 天,500K steps(text-to-motion;action-to-motion 在 HumanAct12 / UESTC 分别训 750K / 2M steps)。这是论文强调的 lightweight——比同时期图像 diffusion 小一两个数量级。


为什么重要

  1. 第一个把 diffusion 成功搬进 motion generation 的工作:奠定了 2023 年之后 text-to-motion、music-to-dance、video-to-motion 的技术基线。被引 1800+,后续 MLD、MoMask、PhysDiff、GMD、Okami 全部以 MDM 为 baseline 或基础。
  2. 「预测 $\hat x_0$ 而不是 $\epsilon$」是 diffusion 进 motion 域的关键工程 trick:让 motion generation 文献积累的 geometric losses(位置/速度/foot contact)能直接接入 diffusion。这个设计选择后来被 BeyondMimic 等把 diffusion 用进物理控制的工作继承。
  3. transformer 替代 U-Net 的成功示范:motion 是时间序列,U-Net 的 2D 卷积优势用不上,transformer encoder-only 更自然。这条经验被后续所有 motion diffusion 工作采纳。
  4. classifier-free guidance 在 motion 域的首次系统化应用:单模型同时支持条件和无条件生成,$s=2.5$ 的 sweet spot 成为后续工作的事实默认。
  5. editing 能力是「副产品」:因为 diffusion 采样过程天然支持 inpainting,MDM 不需重训就支持时间 in-betweening 和身体部位编辑。这是相对 VAE 路线的额外优势。

与 Diffusion Policy 的区别(生成用 vs 控制用)

T05 的 Diffusion Policy 和 MDM 同源不同目标:

维度MDM(生成用)Diffusion Policy(控制用)
目标生成 kinematic motion 序列(动画/视频用)生成机器人 action chunk(控制用)
输出N 帧 × J 关节 × D 维 pose 序列action chunk(关节 target 或 EEF pose)
是否上物理,纯 kinematic,不进物理仿真是,输出进机器人/仿真执行
条件text(CLIP 编码)/ action class视觉观测(RGB/点云)+ proprioception
架构transformer encoder-only1D temporal CNN(U-Net 式)或 transformer
预测目标$\hat x_0$(sample)$\epsilon$(noise)或 $\hat x_0$
训练数据MoCap(HumanML3D / KIT / AMASS机器人 teleop 示教
能否直接喂机器人不能——生成的动作常违反物理(穿地、不平衡、foot sliding)能——输出直接是 action

核心区别一句话:MDM 是「动作」,Diffusion Policy 是「动作」。MDM 生成的 motion 漂亮但不能直接控制机器人,要喂机器人还需要 PHC/UHC 这类 physics-based imitator 当「物理翻译层」(这正是 PHC 论文里用 MDM 当输入做 in-betweening 的用法,本仓库 P-PHCUHC-2023.md)。这是 T08 线索的核心矛盾:「生成」和「控制」之间的物理鸿沟。


局限

  1. 纯 kinematic,不进物理:生成的动作可能穿地、不平衡、foot sliding(虽然 foot contact loss 缓解但仍不根治)。要喂机器人必须经 physics-based imitator(DeepMimic / AMP / PHC)做「物理化」,这是 T08 后续物理化路线(PhysDiff / ReinDiffuse / GMD / BeyondMimic)才系统化解决的。
  2. 采样慢:T=1000 步,没有 DDIM 加速(虽然 MDM 用了 cosine schedule,但仍是 1000 步),实时性差。后续 MLD 用 latent diffusion 把步数压下来。
  3. 数据规模小:HumanML3D 14K motion / KIT 3.9K,相对 AMASS 整体(40h+)仍小。text-to-motion 严重受限于文本标注。
  4. 多模态仍弱:虽然比 VAE 强,但同一 prompt 生成的多样性仍远低于真实人类动作分布。
  5. 无 physical plausibility 保证:geometric losses 是软约束,不能保证生成的动作可执行。
  6. 文本理解受 CLIP 限制:CLIP 文本编码器对细粒度动作描述(如「先迈左脚然后转身」)理解有限。

复现要点

  1. 训练资源:单 RTX 2080 Ti(消费级),3 天,500K steps。batch 64,8 层 transformer,latent dim 512。
  2. 关键超参:T=1000,cosine noise schedule;classifier-free guidance 训练时 10% 置空 $c$,采样 $s=2.5$;geometric loss 权重 $\lambda_\text{pos}, \lambda_\text{vel}, \lambda_\text{foot}$ 论文未在正文给死值,参考开源代码默认。
  3. CLIP:用 frozen CLIP-ViT-B/32 文本编码器,不训练 CLIP。
  4. 数据:HumanML3D(推荐,含 root velocity + joint positions + velocities + rotations + foot contact labels,表示冗余但完整);KIT-ML(小,但历史 baseline 都用它)。
  5. 预测 $\hat x_0$ 的实现:直接让 $G$ 输出 motion 维度,loss 是 $\|x_0 - \hat x_0\|^2$;不是预测 $\epsilon$。这是能否用 geometric loss 的关键。
  6. 编辑:无需训练,只改采样循环——每步用输入子集覆写 $\hat x_0$ 对应维度。
  7. 预期难度:低-中。开源代码(GuyTevet/motion-diffusion-model)可直接复现,单卡 3 天。

相关

  • 建立在:DDPM [Ho et al. 2020](diffusion 母方法);Classifier-Free Guidance [Ho & Salimans 2022](条件 + 无条件同模型);GLIDE / DALL-E 2(预测 $\hat x_0$ 的设计选择);CLIP [Radford et al. 2021](文本编码);transformer [Vaswani et al. 2017](架构);Actor / MotionTransformer(motion generation 的 transformer 先行者);MotionCLIP [Tevet et al. 2022](同作者前作,CLIP latent 路线,MDM 是其 diffusion 升级)。
  • 引出:MLD [Chen et al. 2023](latent diffusion 加速 MDM);PhysDiff [Yuan 2023](给 MDM 加物理约束);MoMask [Guo et al. 2024](masked modeling 替代 diffusion);GMD(把 MDM 推到 3D 空间轨迹/spatial control)、Okami [Li et al. 2024](从单视频学人形操作技能,与 MDM 路线相邻)。在机器人侧,PHC/UHC [Luo et al. 2023](本仓库 P-PHCUHC-2023.md)直接把 MDM 输出当 input 做 in-betweening,是 MDM 进物理控制的桥梁;BeyondMimic [Liao et al. 2025](最终把 motion diffusion 和 physics tracker 真正合流)。
  • 本仓库笔记交叉引用T08-action-gen-physics.md(T08 起点);与 P-DiffusionPolicy-2023.md 是同源技术不同目标(生成 vs 控制);与 P-PHCUHC-2023.md 互补(MDM 生成 → PHC 物理化);BeyondMimic 是 T08 合流点、T04 转折 7,把这两条线焊在一起。