OpenFace+Ubuntu20.04+conda 排坑记录
任务
了解到openface可以实现很多有趣的功能,想把他跑通。
基本流程
按照官方wiki来。
我的系统是20.04,查看gcc,已经是9的版本,感觉应该能兼容8,就没安装g++ -8;
gcc --version
同样,我的cmake也没有动;
Get OpenBLAS这一步我做了;
opencv我感觉自己有过了,后面编译不通过再看,真的有;
dlib我感觉自己有过了,后面编译不通过再看,后面编译不通过,确实没有;
Get Boost (optional):这一步我没做;
后面编译过程,我没有指定用gcc8,也就是直接cmake:
cmake-D CMAKE_BUILD_TYPE=RELEASE ..
其他都一样。
注意
要不要conda应该都一样,最后我是在非conda环境(python3.8环境下进行的编译和运行的),在conda环境下应该也行。
踩坑回顾
1. git clone 过大文件错误
症状描述
执行:
git clone https://github.com/TadasBaltrusaitis/OpenFace.git
报错:
正克隆到 'OpenFace'...
remote: Enumerating objects: 21343, done.
error: RPC 失败。curl 56 GnuTLS recv error (-9): Error decoding the received TLS packet.
fatal: 远端意外挂断了
fatal: 过早的文件结束符(EOF)
fatal: index-pack 失败
解决办法
问gpt,他说
这个错误通常是由于网络连接问题导致的。当使用git clone命令从远程仓库克隆项目时,如果网络连接不稳定或者存在其他网络问题,就会出现类似的错误。
有几种方法可以尝试解决这个问题:
重新尝试:首先,你可以尝试再次运行git clone命令。有时候这种错误是暂时的,重新尝试可能会成功。
使用SSH协议:如果你使用的是HTTPS协议进行git操作,可以尝试切换为SSH协议。这样做需要在GitHub上设置SSH key,并将仓库的远程地址修改为SSH地址。
使用加速器或VPN:有时候网络连接问题可能是由于网络限制或防火墙导致的。使用VPN或者网络加速器可能会解决这个问题。
检查网络连接:确保你的网络连接稳定,没有其他下载或上传操作占用带宽。
如果以上方法都无法解决问题,那么可能需要进一步调查网络连接的稳定性以及可能存在的网络限制问题。
我确信不是我的网络问题,也不是SSH问题。
于是bing一下,根据网友建议,依次执行:
git config --global http.postBuffer 524288000
git config --list
发现已成功设定新的缓存大小,再次git clone,不再有问题。
这几个帖子也给出了这个问题的更多分析,写帖子时候发现的:
参考1
参考2
2. Cmake 找不到dlib错误
症状描述
cmake时报错:
CMake Warning at CMakeLists.txt:149 (find_package):
Could not find a configuration file for package "dlib" that is compatible
with requested version "19.24".
The following configuration files were considered but not accepted:
/usr/local/lib/cmake/dlib/dlibConfig.cmake, version: 19.13.0
CMake Error at CMakeLists.txt:158 (message):
dlib not found in the system, please install dlib
我此前已经在conda虚拟环境中安装了dlib,但这个cmake需要c++编译的。
于是按照按照openface指示安装dlib19.13:
wget http://dlib.net/files/dlib-19.13.tar.bz2;
tar xf dlib-19.13.tar.bz2;
cd dlib-19.13;
mkdir build;
cd build;
cmake ..;
cmake --build . --config Release;
sudo make install;
sudo ldconfig;
cd ../..;
虽然成功了,但也报错:
/usr/local/include/dlib/opencv/cv_image.h:37:29: error: conversion from ‘const cv::Mat’ to non-scalar type ‘IplImage’ {aka ‘_IplImage’} requested
37 | IplImage temp = img;
然后看到网上有些解决办法说这个是版本问题,让改源码,我不想改。
解决办法
看到dlib项目的issue里,dlib作者已经修改了这个错误以适应opencv,于是git最新的dlib,再进行编译安装dlib。
然后再编译openface没有任何错误了。
注意
make install 一个库后,可以直接make install这个库的另一个版本,因为他会自动把之前的版本删掉。
3. 无法加载模型问题
症状描述
按理说,编译完后就能正常运行了。但执行:
./bin/FaceLandmarkImg -fdir "../samples/" -wild
报错:
Attempting to read from directory: ../samples/
Could not find the HAAR face detector location
Loading the model
Reading the landmark detector/tracker from: ./bin/model/main_ceclm_general.txt
Reading the landmark detector module from: ./bin/model/cen_general.txt
Reading the PDM module from: ./bin/model/pdms/In-the-wild_aligned_PDM_68.txt....Done
Reading the Triangulations module from: ./bin/model/tris_68.txt....Done
Reading the intensity CEN patch experts from: ./bin/model/patch_experts/cen_patches_0.25_of.dat....Could not find CEN patch experts, for instructions of how to download them, see https://github.com/TadasBaltrusaitis/OpenFace/wiki/Model-download
ERROR: Could not load the landmark detector
感谢参考博客的分享,按照这个博客所说,下载文件到指定路径,然后再编译一遍就行。
注意
添加完文件后还要再编译一遍才行,否则会报同样错误。