fyyakaxyy / AnimationGPT

AnimationGPT:An AIGC tool for generating game combat motion assets
http://www.animationgpt.net
MIT License
342 stars 33 forks source link
aigc game text-to-motion

AnimationGPT

Project Page Zhihu Bilibili

AnimationGPT is a project focused on generating combat style character animations based on text. This project is trained on the MotionGPT and has produced the first character animation dataset dedicated to combat styles, named CombatMotion, which comes with textual descriptions.

Compare to current text-to-motion dataset

Dataset Motions Texts Style Source
KIT-ML 3,911 6,278 Daily Life Motion Capture
HumanML3D 14,616 44,970 Daily Life Motion Capture
Motion-X 81,084 81,084 Daily Life Video Reconstruction
CMP 8,700 26,100 Combat Game
CMR 14,883 14,883 Combat Game

Compared to the current text-to-motion datasets, CombatMotion has the following characteristics:

  1. Derived from game assets.
  2. Features a fighting style, where the animation style in action games tends to be concentrated, and the types of actions are biased.
  3. More detailed textual annotations.

Combat Motion Dataset

Pipline

  1. Obtain game assets in FBX format, redirect them to SMPL, and read the coordinates of human body joints (refer to Fbx2SMPL);

  2. Add textual annotations. For each animation, manually annotate it from the following aspects: action type, weapon type, attack type, locational words, power descriptor words, speed descriptor words, and confusion descriptor words. A partial list of terms is shown below:

    Action type Weapon type Attack type Locative words Power Speed Fuzzy
    Idle Bare Hand Left-Handed In-Place Light-Weighted Swift Piercing
    Get Hit Sacred Seal Right-Handed Towards Left Steady Relative Fast Slash
    Death Fist One-Handed Towards Right Heavy-Weighted Uniform Speed Blunt

    Then, use GPT-4 to combine these annotations into sentences.

    example annotation

    The diagram above outlines our annotation process. Initially, we fill in seven key descriptive words based on the characteristics of the animation, followed by writing posture description sentences. Subsequently, we use a large language model to integrate these elements into several complete natural language sentences. Finally, we select the sentence that best meets our requirements as the annotation result.

  3. Process the animation and annotated data into a format compatible with HumanML3D.

CombatMotionProcessed Dataset(CMP)

Download: google drive

CombatMotionProcessed(CMP) is a refined dataset that, in terms of character animation, retains 8,700 high-quality animations with a strong fighting style. In terms of textual annotations, we provide three text annotations for each animation: a concise description, a concise description with sensory details, and a detailed description.

Taking CMP008388 as an example, its corresponding text annotations are:

weapon attack a man holding a Katana,executing a Charged Heavy Attack,Dual Wielding,root motion get Forward, Steady,Powerful and Relative Slow,First slow then fast,Cleanly.
weapon attack a man holding a Katana,executing a Charged Heavy Attack,Dual Wielding,root motion get Forward, Steady,Powerful and Relative Slow,First slow then fast,Cleanly,which make a sense of Piercing,Wide Open,Charged,Accumulating strength.
The character grips the wedge with both hands and charges for a powerful strike. They firmly lower their body, twist to the left, lunge forward with a bow step, and stab with the sword held in both hands.

CombatMotionRaw Dataset(CMR)

Download: google drive

CombatMotionRaw (CMR) is an unrefined dataset containing 14,883 animation entries (CMP is a subset of CMR), but each animation is only provided with one textual annotation. Moreover, the textual annotations in CMR consist of simple concatenations of annotated words. It was found during project development that models trained with this type of annotation performed poorly, thus this format was ultimately not adopted.

Example of textual annotation:

weapon attack curved sword curved greatsword right-handed one-handed charged heavy attack forward steady powerful charged accumulating strength cleanly first slow then fast slash smooth and coherent wide open featherlike roundabout lean over and twist your waist to the left step forward with your right leg store your right hand from the left back swing it diagonally downward and swing two circles.

CMR has a richer set of animation data, unfortunately, the annotations are not detailed enough. You can read the textual annotations from the dataset yourself and refine them.

Model and Evaluation

Here are models trained on the CMP dataset using different algorithms:

Evaluation on CMP

Metric MotionGPT MLD MDM
Matching Score↓ 5.426 ± 0.017 5.753 ± 0.019 7.220 ± 0.018
Matching Score (Ground Truth)↓ 5.166 ± 0.012 5.177 ± 0.018 5.179 ± 0.013
R_precision (top 1)↑ 0.044 ± 0.002 0.048 ± 0.002 0.030 ± 0.001
R_precision (top 2)↑ 0.084 ± 0.003 0.089 ± 0.003 0.063 ± 0.002
R_precision (top 3)↑ 0.122 ± 0.003 0.126 ± 0.003 0.096 ± 0.002
R_precision (top 1)(Ground Truth)↑ 0.050 ± 0.002 0.051 ± 0.002 0.053 ± 0.002
R_precision (top 2)(Ground Truth)↑ 0.094 ± 0.002 0.095 ± 0.003 0.097 ± 0.003
R_precision (top 3)(Ground Truth)↑ 0.133 ± 0.003 0.134 ± 0.004 0.136 ± 0.004
FID↓ 0.531 ± 0.018 1.240 ± 0.036 40.395 ± 0.424
Diversity→ 5.143 ± 0.052 5.269 ± 0.044 3.364 ± 0.080
Diversity (Ground Truth)→ 5.188 ± 0.070 5.200 ± 0.049 5.191 ± 0.036
MultiModality ↑ 1.793 ± 0.094 2.618 ± 0.115 2.463 ± 0.102

Tutorial

Windows10 Tutorial

Use the AGPT model trained on the CMP dataset under Windows10:

If you encounter only the first two errors when executing with matplotlib>=3.5.0, you can refer to this issue https://github.com/GuyTevet/motion-diffusion-model/issues/6.

If you are also experiencing unrecognized mp4 files, you need to additionally download ffmpeg, unzip it and modify these contents in tools/animation.py:

import matplotlib.pyplot as plt
plt.rcParams['animation.ffmpeg_path'] = r'D:\\ffmpeg\\bin\\ffmpeg.exe' #ffmpeg floder
from mpl_toolkits.mplot3d import Axes3D

If you have successfully generated a video file after resolving the error, but the video only has a white screen, please try switching to another python version to do the npy file format conversion. tools/requirements.txt provides the necessary dependencies for python=3.9.19 to work properly.

Suggestions

During the process of dataset creation and model training/tuning, you might encounter some issues in aspects like textual annotations, model training, and data augmentation. Based on our experience, we offer the following suggestions:

Model Training Crashes Due to Errors in Textual Annotations

If you process data using the HumanML3D pipeline, you might encounter the following issues, which can lead to model training crashes:

Exploration of Textual Annotations

Mixed Training

Mixing the HumanML3D, KIT-ML, and CMP datasets for model training can result in significant improvements in evaluation metrics.

However, evaluation metrics and visual effects are not equivalent. For some generated results, models trained on a mixed dataset perform worse than those trained solely on the CMP dataset. Because differences in action styles between datasets change the data distribution, thereby affecting model performance.

Motion-X-to-HumanML3D

You can try converting Motion-X into the HumanML3D format for pre-training the model, and then fine-tuning it on the CMP dataset.

Motion-X-to-HumanML3D

Acknowledgments

Our code is partially borrowing from them.

Citation

If you find this repository useful, please consider citing it as follows:

@misc{CombatMotion,
  title={AnimationGPT:An AIGC tool for generating game combat motion assets},
  author={Yihao Liao, Yiyu Fu, Ziming Cheng, Jiangfeiyang Wang},
  year={2024},
  howpublished={\url{https://github.com/fyyakaxyy/AnimationGPT}}
}
@InProceedings{Guo_2022_CVPR,
    author    = {Guo, Chuan and Zou, Shihao and Zuo, Xinxin and Wang, Sen and Ji, Wei and Li, Xingyu and Cheng, Li},
    title     = {Generating Diverse and Natural 3D Human Motions From Text},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2022},
    pages     = {5152-5161}
}
@article{jiang2024motiongpt,
  title={Motiongpt: Human motion as a foreign language},
  author={Jiang, Biao and Chen, Xin and Liu, Wen and Yu, Jingyi and Yu, Gang and Chen, Tao},
  journal={Advances in Neural Information Processing Systems},
  volume={36},
  year={2024}
}

AnimationGPT(中文)

Project Page Zhihu Bilibili

AnimationGPT是一个基于文本生成格斗风格角色动画的项目。本项目基于MotionGPT训练模型,并且制作了首个专注于格斗风格、并配备文本描述的角色动画数据集CombatMotion。

对比现有文本-动作数据集

数据集 动作数量 文本数量 风格 来源
KIT-ML 3,911 6,278 日常 动作捕捉
HumanML3D 14,616 44,970 日常 动作捕捉
Motion-X 81,084 81,084 日常 视频重建
CMP 8,700 26,100 格斗 游戏
CMR 14,883 14,883 格斗 游戏

与现有文本-动作数据集相比,CombatMotion具有如下特点:

  1. 来源于游戏资产。
  2. 具有格斗风格,动作类游戏当中的动画风格相对来说是集中的,动作类型有偏。
  3. 具有更详细的文本标注。

Combat Motion数据集

处理流程

  1. 获取fbx格式的游戏资产,重定向到SMPL,并读取人体关节点坐标(参考Fbx2SMPL);

  2. 添加文本标注。对于每一条动画,首先从动作类型、武器类型、攻击类型、方位词、力量感描述词、速度描述词和困惑描述词这几个方面添加人工标注,部分词表如下所示:

    Action type Weapon type Attack type Locative words Power Speed Fuzzy
    Idle Bare Hand Left-Handed In-Place Light-Weighted Swift Piercing
    Get Hit Sacred Seal Right-Handed Towards Left Steady Relative Fast Slash
    Death Fist One-Handed Towards Right Heavy-Weighted Uniform Speed Blunt

    然后通过GPT-4将这些标注连接成句子。

    example annotation

    上图概述了我们制作标注的过程,首先基于动作动画的特性填写七大类关键描述词,再撰写姿势描述句,随后利用大语言模型将这些要素融合成为数个完整的自然语言句子,最后从中挑选最符合需求的作为标注结果。

  3. 将动画和标注数据处理成HumanML3D格式的数据。

CombatMotionProcessed数据集(CMP)

下载链接:google drive

CombatMotionProcessed(CMP)是精加工的数据集,在角色动画方面,我们保留了高质量、格斗风格强的8,700个动画,在文本标注方面,我们为每一条动画提供了3条文本标注,分别是精简版描述、带有感觉描述的精简版描述和详细版描述。

CMP008388为例,其对应的文本标注是:

weapon attack a man holding a Katana,executing a Charged Heavy Attack,Dual Wielding,root motion get Forward, Steady,Powerful and Relative Slow,First slow then fast,Cleanly.
weapon attack a man holding a Katana,executing a Charged Heavy Attack,Dual Wielding,root motion get Forward, Steady,Powerful and Relative Slow,First slow then fast,Cleanly,which make a sense of Piercing,Wide Open,Charged,Accumulating strength.
The character grips the wedge with both hands and charges for a powerful strike. They firmly lower their body, twist to the left, lunge forward with a bow step, and stab with the sword held in both hands.

CombatMotionRaw数据集(CMR)

下载链接:google drive

CombatMotionRaw(CMR)是未经过精加工的数据集,具备14,883个的动画数据(CMP是CMR的子集),但每条动画只提供一个文本标注。另外,CMR中的文本标注是标注词的简单连接,在项目研发中发现这种标注训练的模型性能较差,因此最终未采用这种格式。

文本标注示例:

weapon attack curved sword curved greatsword right-handed one-handed charged heavy attack forward steady powerful charged accumulating strength cleanly first slow then fast slash smooth and coherent wide open featherlike roundabout lean over and twist your waist to the left step forward with your right leg store your right hand from the left back swing it diagonally downward and swing two circles.

CMR具备更丰富的动画数据,可惜标注不够精细,您可以自行读取数据集中的文本标注并优化。

模型和评估

以下分别是在CMP数据集上用不同算法训练的模型:

CMP数据集上的评估结果

Metric MotionGPT MLD MDM
Matching Score↓ 5.426 ± 0.017 5.753 ± 0.019 7.220 ± 0.018
Matching Score (Ground Truth)↓ 5.166 ± 0.012 5.177 ± 0.018 5.179 ± 0.013
R_precision (top 1)↑ 0.044 ± 0.002 0.048 ± 0.002 0.030 ± 0.001
R_precision (top 2)↑ 0.084 ± 0.003 0.089 ± 0.003 0.063 ± 0.002
R_precision (top 3)↑ 0.122 ± 0.003 0.126 ± 0.003 0.096 ± 0.002
R_precision (top 1)(Ground Truth)↑ 0.050 ± 0.002 0.051 ± 0.002 0.053 ± 0.002
R_precision (top 2)(Ground Truth)↑ 0.094 ± 0.002 0.095 ± 0.003 0.097 ± 0.003
R_precision (top 3)(Ground Truth)↑ 0.133 ± 0.003 0.134 ± 0.004 0.136 ± 0.004
FID↓ 0.531 ± 0.018 1.240 ± 0.036 40.395 ± 0.424
Diversity→ 5.143 ± 0.052 5.269 ± 0.044 3.364 ± 0.080
Diversity (Ground Truth)→ 5.188 ± 0.070 5.200 ± 0.049 5.191 ± 0.036
MultiModality ↑ 1.793 ± 0.094 2.618 ± 0.115 2.463 ± 0.102

使用教程

Windows10使用教程

在Windows10环境下使用训练好的模型:

如果您使用matplotlib>=3.5.0执行时只遇到了前两条报错,可以参考https://github.com/GuyTevet/motion-diffusion-model/issues/6。

如果您也遇到了无法识别mp4文件,需要额外下载ffmpeg,解压并修改tools/animation.py中的:

import matplotlib.pyplot as plt
plt.rcParams['animation.ffmpeg_path'] = r'D:\\ffmpeg\\bin\\ffmpeg.exe' #ffmpeg floder
from mpl_toolkits.mplot3d import Axes3D

如果您解决报错后生成了视频文件,但视频为纯白画面,请尝试换用其他的python版本来做npy文件格式转换tools/requirements.txt提供了python=3.9.19环境下可以正常执行所需的依赖。

建议

在数据集制作和模型训练调优的过程中,您可能会在文本标注、模型训练、数据增强等方面遇到一些问题。基于我们的经验,给出以下建议:

文本标注错误导致模型训练崩溃

如果采用HumanML3D的pipline处理数据,可能会遇到以下问题,它们将会导致模型训练崩溃:

文本标注的探索

混合训练

将HumanML3D、KIT-ML和CMP数据集混合起来训练模型,在评估指标上会带来巨大提升,但评估指标和视觉效果并不等价,对于部分生成结果,混合训练的模型表现不如单独使用CMP数据集训练的模型,这是因为不同数据集动作风格的差异改变了数据分布,进而影响了模型的性能。

Motion-X到HumanML3D的格式转换

可以尝试将Motion-X转换成HumanML3D的格式,用于预训练模型,然后在CMP数据集上微调。

Motion-X-to-HumanML3D

致谢

我们的代码部分借鉴了以上工作。

引用

如果您觉得这个仓库对您有用,请考虑引用:

@misc{CombatMotion,
  title={AnimationGPT:An AIGC tool for generating game combat motion assets},
  author={Yihao Liao, Yiyu Fu, Ziming Cheng, Jiangfeiyang Wang},
  year={2024},
  howpublished={\url{https://github.com/fyyakaxyy/AnimationGPT}}
}
@InProceedings{Guo_2022_CVPR,
    author    = {Guo, Chuan and Zou, Shihao and Zuo, Xinxin and Wang, Sen and Ji, Wei and Li, Xingyu and Cheng, Li},
    title     = {Generating Diverse and Natural 3D Human Motions From Text},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2022},
    pages     = {5152-5161}
}
@article{jiang2024motiongpt,
  title={Motiongpt: Human motion as a foreign language},
  author={Jiang, Biao and Chen, Xin and Liu, Wen and Yu, Jingyi and Yu, Gang and Chen, Tao},
  journal={Advances in Neural Information Processing Systems},
  volume={36},
  year={2024}
}