【OpenFace】 超、凢脫俗 2022-06-12 13:23 132阅读 0赞 OpenFace: [http://cmusatyalab.github.io/openface/][http_cmusatyalab.github.io_openface] # 一、什么是Openface? # Openface是一个基于深度神经网络的开源人脸识别系统。该系统基于谷歌的文章[FaceNet: A Unified Embedding for Face Recognition and Clustering][FaceNet_ A Unified Embedding for Face Recognition and Clustering]。Openface是卡内基梅隆大学的[Brandon Amos][]主导的。 官方地址:[http://cmusatyalab.github.io/openface/][http_cmusatyalab.github.io_openface] 代码:[https://github.com/cmusatyalab/openface][https_github.com_cmusatyalab_openface] # 二、Openface环境搭建 # 系统:Ubuntu 14.04 64位桌面[操作系统][Link 1] 参考:[http://cmusatyalab.github.io/openface/setup/][http_cmusatyalab.github.io_openface_setup] ### 1、Ubuntu切换root用户 ### 此处不详述,如果要用普通用户,请自行[测试][Link 2]。 参考文章: [http://blog.csdn.net/itas109/article/details/50679251][http_blog.csdn.net_itas109_article_details_50679251] ### 2、安装前准备工作 ### 安装必要的程序,可以用下面的批处理,也可以一个一个的进行安装。 **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. \#!/bin/sh 2. sudo apt-get install build-essential -y 3. sudo apt-get install cmake -y 4. sudo apt-get install curl -y 5. sudo apt-get install gfortran -y 6. sudo apt-get install git -y 7. sudo apt-get install libatlas-dev -y 8. sudo apt-get install libavcodec-dev -y 9. sudo apt-get install libavformat-dev -y 10. sudo apt-get install libboost-all-dev -y 11. sudo apt-get install libgtk2.0-dev -y 12. sudo apt-get install libjpeg-dev -y 13. sudo apt-get install liblapack-dev -y 14. sudo apt-get install libswscale-dev -y 15. sudo apt-get install pkg-config -y 16. sudo apt-get install python-dev -y 17. sudo apt-get install python-pip -y 18. sudo apt-get install wget -y 19. sudo apt-get install zip –y **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. \#!/bin/sh 2. sudo apt-get install build-essential -y 3. sudo apt-get install cmake -y 4. sudo apt-get install curl -y 5. sudo apt-get install gfortran -y 6. sudo apt-get install git -y 7. sudo apt-get install libatlas-dev -y 8. sudo apt-get install libavcodec-dev -y 9. sudo apt-get install libavformat-dev -y 10. sudo apt-get install libboost-all-dev -y 11. sudo apt-get install libgtk2.0-dev -y 12. sudo apt-get install libjpeg-dev -y 13. sudo apt-get install liblapack-dev -y 14. sudo apt-get install libswscale-dev -y 15. sudo apt-get install pkg-config -y 16. sudo apt-get install python-dev -y 17. sudo apt-get install python-pip -y 18. sudo apt-get install wget -y 19. sudo apt-get install zip –y ### 3、安装必要的库 ### **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. pip2 install numpy scipy pandas 2. pip2 install scikit-learn scikit-image **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. pip2 install numpy scipy pandas 2. pip2 install scikit-learn scikit-image 注意: a.如果出现某一个安装失败的情况,可以一个一个的安装 b.提高pip安装速度 可以更换pip镜像加快下载速度 建立./pip/pip.conf,输入以下内容(或者其他可用镜像): **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. \[global\] 2. timeout = 6000 3. index-url = http://pypi.douban.com/simple 4. 5. \[install\] 6. use-mirrors = **true** 7. mirrors = <a target=\_blank href="http://pypi.douban.com/">http://pypi.douban.com/</a> **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. \[global\] 2. timeout = 6000 3. index-url = http://pypi.douban.com/simple 4. 5. \[install\] 6. use-mirrors = **true** 7. mirrors = <a target=\_blank href="http://pypi.douban.com/">http://pypi.douban.com/</a> c.报错:SSLError: The read operation timed out 可以用下列指令将延时加长 **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. pip2 -install scikit-image --timeout 100 **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. pip2 -install scikit-image --timeout 100 ### 4、安装Torch ### a.安装依赖 **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. curl -shttps://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash –e **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. curl -shttps://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash –e b.安装 **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. git clone https://github.com/torch/distro.git ~/torch --recursive 2. cd ~/torch && ./install.sh **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. git clone https://github.com/torch/distro.git ~/torch --recursive 2. cd ~/torch && ./install.sh c.安装依赖 luarocks install $NAME, where `$NAME` is as listed below. [**dpnn**][dpnn] [**nn**][nn] [**csvigo**][csvigo] [**cunn**][cunn] **(使用CUDA)** [**fblualib**][fblualib] **(仅为了训练**[**DNN**][DNN]**)** [**torchx**][torchx] **(仅为了训练**[**DNN**][DNN]**)** 命令行,按照需要安装: **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. ~/torch/install/bin/luarocks install dpnn 2. ~/torch/install/bin/luarocks install nn 3. ~/torch/install/bin/luarocks install optim 4. ~/torch/install/bin/luarocks install csvigo 5. ~/torch/install/bin/luarocks install cunn 6. ~/torch/install/bin/luarocks install fblualib 7. ~/torch/install/bin/luarocks install torchx **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. ~/torch/install/bin/luarocks install dpnn 2. ~/torch/install/bin/luarocks install nn 3. ~/torch/install/bin/luarocks install optim 4. ~/torch/install/bin/luarocks install csvigo 5. ~/torch/install/bin/luarocks install cunn 6. ~/torch/install/bin/luarocks install fblualib 7. ~/torch/install/bin/luarocks install torchx d.验证是否安装依赖成功 用th命令验证 注意: a.gitclone更新网络老中断 [Git][] submodule update --init –recursive 或者torch目录下的 Update.sh 建议用Update.sh解决 b.错误: Cloning into'extra/luaffifb'... remote:Counting objects: 918, done. error: RPCfailed; result=56, HTTP code = 200| 0 bytes/s fatal: Theremote end hung up unexpectedly fatal: earlyEOF fatal:index-pack failed Clone of 'https://github.com/facebook/luaffifb' intosubmodule path 'extra/luaffifb' failed 解决: **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. git config --global http.postBuffer 524288000 **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. git config --global http.postBuffer 524288000 ### 5、安装opencv ### [OpenCV][]版本为2.4.11,下载地址:[https://github.com/Itseez/opencv/archive/2.4.11.zip][https_github.com_Itseez_opencv_archive_2.4.11.zip] 编译参考:[http://docs.opencv.org/2.4/doc/tutorials/introduction/linux\_install/linux\_install.html][http_docs.opencv.org_2.4_doc_tutorials_introduction_linux_install_linux_install.html] a.指令下载: **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. cd ~ 2. mkdir -p src 3. cd src 4. curl -L https://github.com/Itseez/opencv/archive/2.4.11.zip -o ocv.zip **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. cd ~ 2. mkdir -p src 3. cd src 4. curl -L https://github.com/Itseez/opencv/archive/2.4.11.zip -o ocv.zip b.解压: **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. unzip ocv.zip **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. unzip ocv.zip c.编译: **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. cd opencv-2.4.11 2. mkdir release 3. cd release 4. cmake -D CMAKE\_BUILD\_TYPE=RELEASE -D CMAKE\_INSTALL\_PREFIX=/usr/local .. 5. make -j8 6. make install **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. cd opencv-2.4.11 2. mkdir release 3. cd release 4. cmake -D CMAKE\_BUILD\_TYPE=RELEASE -D CMAKE\_INSTALL\_PREFIX=/usr/local .. 5. make -j8 6. make install ### ### d.验证 import cv2 ### 6、安装dlib ### dlib v18.16下载地址:[https://github.com/davisking/dlib/releases/download/v18.16/dlib-18.16.tar.bz2][https_github.com_davisking_dlib_releases_download_v18.16_dlib-18.16.tar.bz2] a.安装编译 **\[html\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. mkdir -p ~/src 2. cd ~/src tar xf dlib-18.16.tar.bz2 3. cd dlib-18.16/python\_examples 4. mkdir build 5. cd build 6. cmake ../../tools/python 7. cmake --build . --config Release 8. cp dlib.so /usr/local/lib/python2.7/dist-packages **\[html\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. mkdir -p ~/src 2. cd ~/src tar xf dlib-18.16.tar.bz2 3. cd dlib-18.16/python\_examples 4. mkdir build 5. cd build 6. cmake ../../tools/python 7. cmake --build . --config Release 8. cp dlib.so /usr/local/lib/python2.7/dist-packages b.确保 在a中最后一条命令中,确保路径在默认的[Python][]路径,可以在[Python][Python 1]解释器里面用sys.path查找 For the final command, make sure the directory is in your default [Python][Python 1] path, which can be found with`sys.path` in a [python][Python 1] interpreter. c.验证 **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. import dlib **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. import dlib ### 7、Git获取openface ### a.下载Openface **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. git clone https://github.com/cmusatyalab/openface.git 2. git submodule init 3. git submodule update **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. git clone https://github.com/cmusatyalab/openface.git 2. git submodule init 3. git submodule update b.在Openface根目录执行 **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. sudo python2 setup.py install **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. sudo python2 setup.py install python2一定要确保dlib和[OpenCV][]安装成功 **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. import cv2 2. import dlib **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. import cv2 2. import dlib c.获取模型 **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. models/get-models.sh **\[cpp\]** [view plain][] [copy][view plain] [![在CODE上查看代码片][CODE]][CODE_CODE] [![派生到我的代码片][ico_fork.svg]][ico_fork.svg 1] 1. models/get-models.sh ### 8、运行demo ### 运行demo1: ./demos/compare.pyimages/examples/\{lennon\*,clapton\*\} 运行demo2: ./demos/classifier.py infermodels/openface/celeb-classifier.nn4.small2.v1.pkl ./images/examples/carell.jpg 运行demo3: ./demos/web/start-servers.sh ### 9、demo1可用浏览器 ### 可用浏览器: 360浏览器极速模式 火狐浏览器 搜狗浏览器高速模式 不可用浏览器: Chrome谷歌浏览器(可能与浏览器更新有关系,getUserMedia()) IE览器 [http_cmusatyalab.github.io_openface]: http://cmusatyalab.github.io/openface/ [FaceNet_ A Unified Embedding for Face Recognition and Clustering]: http://www.cv-foundation.org/openaccess/content_cvpr_2015/app/1A_089.pdf [Brandon Amos]: http://bamos.github.io/ [https_github.com_cmusatyalab_openface]: https://github.com/cmusatyalab/openface [Link 1]: http://lib.csdn.net/base/operatingsystem [http_cmusatyalab.github.io_openface_setup]: http://cmusatyalab.github.io/openface/setup/ [Link 2]: http://lib.csdn.net/base/softwaretest [http_blog.csdn.net_itas109_article_details_50679251]: http://blog.csdn.net/itas109/article/details/50679251 [view plain]: http://blog.csdn.net/ren1335654481/article/details/54563906# [CODE]: https://code.csdn.net/assets/CODE_ico.png [CODE_CODE]: https://code.csdn.net/snippets/1596253 [ico_fork.svg]: https://code.csdn.net/assets/ico_fork.svg [ico_fork.svg 1]: https://code.csdn.net/snippets/1596253/fork [dpnn]: https://github.com/nicholas-leonard/dpnn [nn]: https://github.com/torch/nn [csvigo]: https://github.com/clementfarabet/lua---csv [cunn]: https://github.com/torch/cunn [fblualib]: https://github.com/facebook/fblualib [DNN]: http://cmusatyalab.github.io/openface/training-new-models/ [torchx]: https://github.com/nicholas-leonard/torchx [Git]: http://lib.csdn.net/base/git [OpenCV]: http://lib.csdn.net/base/opencv [https_github.com_Itseez_opencv_archive_2.4.11.zip]: https://github.com/Itseez/opencv/archive/2.4.11.zip [http_docs.opencv.org_2.4_doc_tutorials_introduction_linux_install_linux_install.html]: http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html [https_github.com_davisking_dlib_releases_download_v18.16_dlib-18.16.tar.bz2]: https://github.com/davisking/dlib/releases/download/v18.16/dlib-18.16.tar.bz2 [Python]: http://lib.csdn.net/base/11 [Python 1]: http://lib.csdn.net/base/python
相关 【OpenFace】 OpenFace: [http://cmusatyalab.github.io/openface/][http_cmusatyalab.github.io_openface] 超、凢脫俗/ 2022年06月12日 13:23/ 0 赞/ 133 阅读
相关 openface中实例化AlignDlib的优化 最近在做人脸识识别,使用的是openface框架结构。开发出来之后可以使用,但是效率比较慢,时间大概在1.8s左右。这个速度根本无法满足使用需要。于是,由于工作需要便开始优化识 骑猪看日落/ 2022年06月02日 04:27/ 0 赞/ 177 阅读
相关 关于openface开发遇到的问题 最近在做一个人脸识别,使用的开源框架openface。 官网地址(openface):http://cmusatyalab.github.io/openface/ 这篇文章 Myth丶恋晨/ 2022年06月02日 00:54/ 0 赞/ 346 阅读
相关 看OpenFace如何做到精准人脸识别 > 原文:[https://blog.algorithmia.com/understanding-facial-recognition-openface/][https_blo 绝地灬酷狼/ 2022年06月01日 11:48/ 0 赞/ 245 阅读
相关 [实现] 安装 TadasBaltrusaitis/OpenFace 并修改代码逻辑 > 最近需要用 TadasBaltrusaitis/OpenFace 做一个 Demo,安装与修改代码的过程十分繁琐,所以以本文进行记录,给需要的人留个参考。 > 链接:h 蔚落/ 2022年02月26日 13:35/ 0 赞/ 333 阅读
还没有评论,来说两句吧...