项目代码网址:GitHub - radekd91/emoca: Official repository accompanying a CVPR 2022 paper EMOCA: Emotion Driven Monocular Face Capture And Animation. EMOCA takes a single image of a face as input and produces a 3D reconstruction. EMOCA sets the new standard on reconstructing highly emotional images in-the-wildhttps://github.com/radekd91/emoca
项目介绍:
此项目是CVPR 2022 论文 EMOCA: Emotion Driven Monoocular Face Capture And Animation 的官方代码 。 EMOCA 将人脸的单个图像作为输入并生成 3D 重建。 EMOCA 设定了在自然场景下重建高度情绪化图像的新标准。EMOCA(EMOtion Capture and Animation)(情绪捕捉和动画)
主要以GitHub页面给出的项目说明来操作运行,遇到问题再一个一个解决
conda install -n base conda-forge::mamba
(base) C:\Users\XXX>
代表的是在这个路径下执行一些操作,而我们的操作要在我们刚刚下载的路径里面执行,故需要改变路径,输入如下代码,cd 后面是我们下载的资源的路径。
(base) C:\Users\XXX>D:
(base) D:\>cd D:\emoca\emoca-release-EMOCA
之后便可在该路径下操作
(base) D:\emoca\emoca-release-EMOCA>
bash install.sh
但是此时又出现了错误,找不到bash这个命令,后面查找教程,发现bash貌似是Linux命令,无法直接在Windows系统中使用,需要在命令行输入如下代码,之后问题解决
conda install m2-base
继续输入bash install.sh,让脚本开始下载,并构件我们要想的conda environment,名字是
work36_cu11,但是很不幸,遇到了项目作者提到的无法预料的问题,一片红,部分错误如下
An unexpected error has occurred. Conda has prepared the above report.
Could not find conda environment: work36_cu11
You can list all discoverable environments with `conda info --envs`.
查看教程,有个方法是输入如下代码conda clean -i再重启anaconda prompt,然而,操作了一下还是没用,仍然是相同的报错,命令行输入conda info --envs也没有出现想要的环境,因此可能需要尝试项目作者给出的长版本
根据作者提示,短版本配置环境失效则用长版本来配置。
bash pull_submodules.sh
出现如下错误
git: command not found
查找教程,发现出现这种原因是未将git添加到系统变量里,于是加入系统变量后继续输入上面的代码,可以运行起来,但是由于项目文件太大的原因clone不下来,因此根据错误提示,从对应的网站中手动下载相应的文件,再复制到对应的文件夹中,这一步就完成了。
根据项目提示,用以下代码创建一个环境
mamba env create python=3.6 --file conda-environment_py36_cu11_ubuntu.yml
经过一段时间的包的下载,又出现了如下错误
An unexpected error has occurred. Conda has prepared the above report.
查找解决方案,第一种,清理conda,用代码conda clean -i,然后重启conda,再次创建,未解决问题;第二种,使用代码conda clean --packages && conda clean --all && conda update --all,再重启conda继续创建,问题依然存在;第三种,删除C:\Users[user_name].condarc文件,之后重启conda,继续创建,未解决问题;第四种,关闭VPN,但是我未开启VPN。项目停滞
卸载电脑上的python,pycharm,anaconda,删除环境变量,重新开始本项目。
channels:
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
InvalidArchiveError("Error with archive C:\\Users\\金兴亮\\.conda\\pkgs\\conda-4.12.0-py39haa95532_0_mw7kqxr\\info-conda-4.12.0-py39haa95532_0.tar.zst. You probably need to delete and re-download or re-create this file. Message from libarchive was:\n\nFailed to open 'C:\\Users\\XXX\\.conda\\pkgs\\conda-4.12.0-py39haa95532_0_mw7kqxr\\info-conda-4.12.0-py39haa95532_0.tar.zst'")
执行命令conda install -n base conda-forge::mamba安装mamba,安装成功。
直接从长版本开始操作,运行bash pull_submodules.sh,提示git:command not found。原因是未下载git,于是通过指令conda install git安装git,并将C:\ProgramData\Anaconda3\Library\cmd路径添加到环境变量里,重新运行bash pull_submodules.sh,运行成功
随后执行mamba env create python=3.6 --file conda-environment_py36_cu11_ubuntu.yml,按照文件创建环境,然而还是出现同样的问题,错误报告如下:
在搭建环境之前,还对ubuntu系统进行了一些设置,操作记录在另一篇博文上:link
//输入以下命令查看驱动对应的cuda版本
nvidia-smi
//进入官网找到对应版本的cuda安装界面,选择自己的版本,再按照提示依次输入以下命令
wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run
sudo sh cuda_11.4.0_470.42.01_linux.run
//开始安装会弹出窗口,依次点击continue,输入accept,enter取消对驱动的安装,再选择install即开始安装
//安装完成后,会有一个Summary提示,这是正确安装的样子,接下来添加环境变量
//输入以下指令,打开.bashrc文件
sudo gedit ~/.bashrc
//随后在弹出的文件中最后面加上下面的这些代码
export PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda/lib64
//save保存,然后输入以下命令,使更改的环境变量生效
source .bashrc
//最后验证是否安装成功
nvcc -V
//输出了版本信息即安装成功
//进一步验证,使用cuda的测试样例
cd /usr/local/cuda-11.4/samples/1_Utilities/deviceQuery
sudo make
sudo ./deviceQuery
//最后输出显示Result=PASS即大功告成
//进入官网https://www.anaconda.com/products/individual,下载对应的安装包
//进入下载文件的目录内,输入以下命令开始安装
bash Anaconda3-2021.11-Linux-x86_64.sh
//一路回车加yes完成安装
//配置环境变量
sudo gedit ~/.bashrc
//添加以下代码
export PATH="/home/kayer/anaconda3/bin:$PATH"
//使其生效
source ~/.bashrc
conda install -n base conda-forge::mamba
//安装会卡住,耐心等待
//首先安装配置好git,然后输入以下命令
git clone https://github.com/radekd91/emoca.git
执行bash install.sh,install.sh文件内容如下,观察终端的运行过程
#!/bin/bash
if ! command -v mamba &> /dev/null
then
echo "mamba could not be found. Please install mamba before running this script"
exit
fi
echo "Pulling submodules"
bash pull_submodules.sh
echo "Creating conda environment"
mamba env create python=3.6 --file conda-environment_py36_cu11_ubuntu.yml
eval "$(conda shell.bash hook)" # make sure conda works in the shell script
conda activate work36_cu11
echo "Installing GDL"
pip install Cython==0.29
pip install -e .
echo "Making sure Pytorch3D installed correctly"
pip install git+https://github.com/facebookresearch/[email protected]
echo "Installation finished"
Transaction
Prefix: /home/paker/anaconda3/envs/work36_cu11
随后提示要下载安装一些文件,等待
Summary:
Install: 193 packages
Total download: 3 GB
下载过程中有几个包下载了一部分就下不动了,最后就出现了如下错误
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
CondaError: Downloaded bytes did not match Content-Length
url: https://conda.anaconda.org/anaconda/linux-64/numba-0.53.1-py36ha9443f7_0.tar.bz2
target_path: /home/paker/anaconda3/pkgs/numba-0.53.1-py36ha9443f7_0.tar.bz2
Content-Length: 3858173
downloaded bytes: 3126274
("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
Could not find conda environment: work36_cu11
You can list all discoverable environments with `conda info --envs`.
故重新开始,按照Long Version一步一步搭建环境。
因为拉取子模块完成,故直接从创建环境开始
mamba env create python=3.6 --file conda-environment_py36_cu11_ubuntu.yml
这时候发现要下载的包少了很多,只有40mb,随后也成功下载,成功创建环境
done
#
# To activate this environment, use
#
# $ conda activate work36_cu11
#
# To deactivate an active environment, use
#
# $ conda deactivate
输入conda info --envs 有以下输出
# conda environments:
#
base * /home/paker/anaconda3
work36_cu11 /home/paker/anaconda3/envs/work36_cu11
pip install Cython==0.29.14
安装成功。
安装gdl,使用-e选项
pip install -e .
下载安装一段时间后,出现了以下报错
ERROR: Could not find a version that satisfies the requirement pytorch3d (unavailable) (from gdl) (from versions: 0.0.1, 0.1.1, 0.2.0, 0.2.5, 0.3.0)
ERROR: No matching distribution found for pytorch3d (unavailable)
此时,按照作者指示单独安装pytorch3D
pip install git+https://github.com/facebookresearch/[email protected]
安装成功后,再次安装gdl,又出现如下报错
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
dask 2021.3.1 requires partd>=0.3.10, which is not installed.
告诉我需要安装partd>=0.3.10,于是单独安装以下它
pip install partd==0.3.10
成功安装,再次安装gdl,输出结果如下,安装完成
Installing collected packages: GDL
Attempting uninstall: GDL
Found existing installation: GDL 0.0.2
Uninstalling GDL-0.0.2:
Successfully uninstalled GDL-0.0.2
Running setup.py develop for GDL
Successfully installed GDL-0.0.2
至此,环境成功搭建。
根据readme里面的指示进入不同的页面运行不同的项目
进入EMOCA页面,按照readme操作
cd emoca/gdl_apps/EMOCA/demos
bash download_assets.sh
资源下载需要一定时间
激活环境
conda activate work36_cu11
单一图像
python demos/test_emoca_on_images.py
运行这个命令来测试EMOCA的一些例子,出现如下错误
Traceback (most recent call last):
File "demos/test_emoca_on_images.py", line 21, in
from gdl_apps.EMOCA.utils.load import load_model
File "/home/paker/emoca/gdl_apps/EMOCA/utils/load.py", line 6, in
from gdl.models.DECA import DecaModule
File "/home/paker/emoca/gdl/models/DECA.py", line 29, in
from pytorch_lightning import LightningModule
File "/home/paker/anaconda3/envs/work36_cu11/lib/python3.6/site-packages/pytorch_lightning/__init__.py", line 20, in
from pytorch_lightning import metrics # noqa: E402
File "/home/paker/anaconda3/envs/work36_cu11/lib/python3.6/site-packages/pytorch_lightning/metrics/__init__.py", line 15, in
from pytorch_lightning.metrics.classification import ( # noqa: F401
File "/home/paker/anaconda3/envs/work36_cu11/lib/python3.6/site-packages/pytorch_lightning/metrics/classification/__init__.py", line 14, in
from pytorch_lightning.metrics.classification.accuracy import Accuracy # noqa: F401
File "/home/paker/anaconda3/envs/work36_cu11/lib/python3.6/site-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in
from pytorch_lightning.metrics.utils import deprecated_metrics, void
File "/home/paker/anaconda3/envs/work36_cu11/lib/python3.6/site-packages/pytorch_lightning/metrics/utils.py", line 22, in
from torchmetrics.utilities.data import get_num_classes as _get_num_classes
ImportError: cannot import name 'get_num_classes'
网上搜索发现是torchmetrics版本问题,原来的版本是0.8,要改成0.5才行,输入以下命令完成更改
conda uninstall torchmetrics
pip install torchmetrics==0.5.1
继续执行代码python demos/test_emoca_on_images.py,就没有报这个错误了,但是又有一个新的错误如下
Traceback (most recent call last):
File "demos/test_emoca_on_images.py", line 21, in
from gdl_apps.EMOCA.utils.load import load_model
File "/home/paker/emoca/gdl_apps/EMOCA/utils/load.py", line 6, in
from gdl.models.DECA import DecaModule
File "/home/paker/emoca/gdl/models/DECA.py", line 25, in
import torch
File "/home/paker/anaconda3/envs/work36_cu11/lib/python3.6/site-packages/torch/__init__.py", line 197, in
from torch._C import * # noqa: F403
ImportError: /home/paker/anaconda3/envs/work36_cu11/lib/python3.6/site-packages/torch/lib/libtorch_python.so: undefined symbol: PySlice_Unpack
网上搜索发现是python的版本3.6.0与pytorch不匹配,要将python升级为3.6.2,操作如下
conda install python=3.6.2
随后继续执行刚才的命令python demos/test_emoca_on_images.py,随后就开始下载一些东西,一些.ph文件,之后有一个运行进度条,最后全部运行完成
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 554/554 [07:41<00:00, 1.20it/s]
Done
(work36_cu11) paker@paker-TUF-Gaming-FX505GE-FX86FE:~/emoca/gdl_apps/EMOCA$
上述例子保存在/emoca/gdl_apps/EMOCA/image_output文件夹内
接着运行下自己找的照片
python demos/test_emoca_on_images.py --input_folder "/home/paker/Downloads/image_input" --output_folder "/home/paker/Downloads/image_output" --model_name EMOCA
python demos/test_emoca_on_video.py --input_video "/home/paker/Downloads/video_input/video_test.mp4" --output_folder "/home/paker/Downloads/video_output" --model_name EMOCA
先按照情绪检测项目提示,下载一些assets,随后输入以下命令运行情绪检测
python demos/test_emotion_recognition_on_images.py --input_folder "/home/paker/Downloads/image_input" --output_folder "/home/paker/Downloads/image_output" --modeltype 3dmm --model_name EMOCA-emorec
随后出现以下问题
FileNotFoundError: [Errno 2] No such file or directory: '/is/cluster/work/rdanecek/emoca/finetune_deca/2021_11_09_19-05-01_5101174495546322475_ExpDECA_Affec_clone_NoRing_EmoB_F2_DeSegrend_BlackB_Aug_early/detail/checkpoints/last.ckpt'
暂未解决。。。
conda update -n base conda #update最新版本的conda
conda create -n xxxx python=3.5 #创建python3.5的xxxx虚拟环境
conda activate xxxx #开启xxxx环境
conda deactivate #关闭环境
conda info --envs #显示所有的虚拟环境
conda clean -i #清理
cd xxx #转到xxx路径里去