本代码库是CVPR 2024论文通过神经合成分析实现3D面部表情的官方实现。
<p align="center"> <a href='https://arxiv.org/abs/2404.04104' style='padding-left: 0.5rem;'> <img src='https://img.shields.io/badge/arXiv-2404.04104-brightgreen' alt='arXiv'> </a> <a href='https://www.youtube.com/watch?v=8ZVgr41wxbk' style='padding-left: 0.5rem;'> <img src='https://img.shields.io/badge/Video-Youtube-red?style=flat&logo=youtube&logoColor=red' alt='Youtube Video'> </a> <a href='https://georgeretsi.github.io/smirk/' style='padding-left: 0.5rem;'> <img src='https://img.shields.io/badge/Website-Project Page-blue?style=flat&logo=Google%20chrome&logoColor=blue' alt='Project Page'> </a> </p> <p align="center"> <img src="https://yellow-cdn.veclightyear.com/ab5030c0/69ece6be-a62f-4672-9a1a-e9e400c411d3.png"> SMIRK从单目图像重建3D面部,其面部几何形状能够忠实地还原极端、不对称和细微的表情。 </p>你需要安装有效版本的PyTorch和Pytorch3D。我们提供了一个requirements.txt
文件,可用于为Python 3.9和CUDA 11.7的环境安装必要的依赖项:
conda create -n smirk python=3.9 pip install -r requirements.txt # 现在安装pytorch3d pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py39_cu117_pyt201/download.html
然后,要下载所需的模型,请运行:
bash quick_install.sh
上述安装包括下载FLAME模型。这需要注册。如果你没有账号,可以在https://flame.is.tue.mpg.de/注册
该命令还将下载SMIRK预训练模型,也可以在Google Drive上找到。
我们提供了两个演示。一个可用于在单张图像上测试模型,
python demo.py --input_path samples/test_image2.png --out_path results/ --checkpoint pretrained_models/SMIRK_em1.pt --crop
另一个可用于在视频上测试模型,
python demo_video.py --input_path samples/dafoe.mp4 --out_path results/ --checkpoint pretrained_models/SMIRK_em1.pt --crop --render_orig
SMIRK在以下数据集的组合上进行了训练:LRS3、MEAD、CelebA和FFHQ。
下载数据集后,我们需要使用mediapipe和FAN提取关键点。我们在datasets/preprocess_scripts
中提供了预处理脚本。示例用法:
python datasets/preprocess_scripts/apply_mediapipe_to_dataset.py --input_dir PATH_TO_FFHQ256/images --output_dir PATH_TO_FFHQ256/mediapipe_landmarks
对于FAN:
python datasets/preprocess_scripts/apply_fan_to_dataset.py --input_dir PATH_TO_FFHQ256/images --output_dir PATH_TO_FFHQ256/fan_landmarks
注意,为了获取FAN关键点,我们使用了https://github.com/hhj1897/face_alignment中的实现。
接下来,确保更新configs
中的配置文件,使其包含正确的数据集和关键点路径。
在预训练阶段,我们仅使用提取的关键点和MICA的输出来训练所有3个编码器(姿态、形状和表情)。
python train.py configs/config_pretrain.yaml train.log_path="logs/pretrain"
预训练后,在SMIRK的核心阶段,我们冻结形状和姿态编码器,并使用完整的SMIRK框架(重建路径和循环路径)训练表情编码器。
python train.py configs/config_train.yaml resume=logs/pretrain/first_stage_pretrained_encoder.pt train.loss_weights.emotion_loss=1.0
如果你发现这项工作有用,请考虑引用:
@inproceedings{SMIRK:CVPR:2024, title = {3D Facial Expressions through Analysis-by-Neural-Synthesis}, author = {Retsinas, George and Filntisis, Panagiotis P., and Danecek, Radek and Abrevaya, Victoria F. and Roussos, Anastasios and Bolkart, Timo and Maragos, Petros}, booktitle = {Conference on Computer Vision and Pattern Recognition (CVPR)}, year = {2024} }
我们感谢在这项工作中使用的以下代码库和论文: