Home

Awesome

AnimationGPT

ZhiHu | Bilibili | YouTube

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.

Remarks: Our online server has expired. If you want to use it, please configure the environment locally.

<video width="100%" height="auto" controls> <source src="README.assets/videoDemo.mp4" type="video/mp4"> </video>

Compare to current text-to-motion dataset

DatasetMotionsTextsStyleSource
KIT-ML3,9116,278Daily LifeMotion Capture
HumanML3D14,61644,970Daily LifeMotion Capture
Motion-X81,08481,084Daily LifeVideo Reconstruction
CMP8,70026,100CombatGame
CMR14,88314,883CombatGame

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 typeWeapon typeAttack typeLocative wordsPowerSpeedFuzzy
    IdleBare HandLeft-HandedIn-PlaceLight-WeightedSwiftPiercing
    Get HitSacred SealRight-HandedTowards LeftSteadyRelative FastSlash
    DeathFistOne-HandedTowards RightHeavy-WeightedUniform SpeedBlunt

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

    exampleannotation

    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:

Download evaluator: google drive

Evaluation on CMP

MethodsMultiModal Distance ↓R-Precision (top 1)↑R-Precision (top 2)↑R-Precision(top 3)↑FID ↓Diversity →MultiModality ↑
Ground Truth3.850±0.0180.335±0.0040.513±0.0050.628±0.0050.006±0.00310.098±0.102/
T2M4.962±0.0310.252±0.0060.406±0.0050.508±0.0061.898±0.0598.975±0.1134.470±0.112
T2M-GPT3.701±0.0270.353±0.0050.545±0.0060.663±0.0050.177±0.01610.128±0.1321.798±0.041
MDM8.414±0.0480.049±0.0030.098±0.0050.148±0.0059.467±0.2177.608±0.1005.682±0.203
MLD4.331±0.0290.293±0.0040.459±0.0030.568±0.0040.628±0.0389.741±0.0933.035±0.138
MMM3.621±0.0200.353±0.0040.545±0.0040.667±0.0050.151±0.01310.091±0.0860.757±0.042
MoMask4.138±0.0250.301±0.0050.481±0.0040.597±0.0050.383±0.0189.689±0.0921.968±0.049
MotionGPT4.228±0.0320.306±0.0040.486±0.0060.605±0.0060.267±0.0179.357±0.1332.210±0.137

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(中文)

ZhiHu | Bilibili | YouTube

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

**备注:**我们的线上服务器已经过期,如需使用,请在本地配置环境。

<video width="100%" height="auto" controls> <source src="README.assets/videoDemo.mp4" type="video/mp4"> </video>

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

数据集动作数量文本数量风格来源
KIT-ML3,9116,278日常动作捕捉
HumanML3D14,61644,970日常动作捕捉
Motion-X81,08481,084日常视频重建
CMP8,70026,100格斗游戏
CMR14,88314,883格斗游戏

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

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

Combat Motion数据集

处理流程

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

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

    Action typeWeapon typeAttack typeLocative wordsPowerSpeedFuzzy
    IdleBare HandLeft-HandedIn-PlaceLight-WeightedSwiftPiercing
    Get HitSacred SealRight-HandedTowards LeftSteadyRelative FastSlash
    DeathFistOne-HandedTowards RightHeavy-WeightedUniform SpeedBlunt

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

    exampleannotation

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

  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数据集上用不同算法训练的模型:

下载评估文件: google drive

CMP数据集上的评估结果

MethodsMultiModal Distance ↓R-Precision (top 1)↑R-Precision (top 2)↑R-Precision(top 3)↑FID ↓Diversity →MultiModality ↑
Ground Truth3.850±0.0180.335±0.0040.513±0.0050.628±0.0050.006±0.00310.098±0.102/
T2M4.962±0.0310.252±0.0060.406±0.0050.508±0.0061.898±0.0598.975±0.1134.470±0.112
T2M-GPT3.701±0.0270.353±0.0050.545±0.0060.663±0.0050.177±0.01610.128±0.1321.798±0.041
MDM8.414±0.0480.049±0.0030.098±0.0050.148±0.0059.467±0.2177.608±0.1005.682±0.203
MLD4.331±0.0290.293±0.0040.459±0.0030.568±0.0040.628±0.0389.741±0.0933.035±0.138
MMM3.621±0.0200.353±0.0040.545±0.0040.667±0.0050.151±0.01310.091±0.0860.757±0.042
MoMask4.138±0.0250.301±0.0050.481±0.0040.597±0.0050.383±0.0189.689±0.0921.968±0.049
MotionGPT4.228±0.0320.306±0.0040.486±0.0060.605±0.0060.267±0.0179.357±0.1332.210±0.137

使用教程

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}
}