caffe实现年龄及性别预测

Posted smbx-ztbz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了caffe实现年龄及性别预测相关的知识,希望对你有一定的参考价值。

一、相关代码及训练好的模型

eveningglow/age-and-gender-classification: Age and Gender Classification using Convolutional Neural Network  https://github.com/eveningglow/age-and-gender-classification


二、部署

1、打开Caffe.sln工程,编译方法见:https://www.cnblogs.com/smbx-ztbz/p/9380273.html

2、将相关源文件及模型拷贝至如下目录:

技术分享图片

3、在examples中新建工程,且将对应源码添加进来

技术分享图片

4、属性设置:

(1)进入“C/C++”,选中“常规”,“附加包含目录”输入如下:

D:Projectscaffe_gpucaffeuildinclude
D:Projectscaffe_gpucaffeuild
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesincludeoost-1_61
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesinclude
C:Program FilesNVIDIA GPU Computing ToolkitCUDAv8.0include
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesincludeopencv
D:Projectscaffe_gpucaffeinclude
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesInclude

其中tingpan改成自己电脑的用户名。

(2) “C/C++” –>“预处理器”—> “预处理器定义”, 输入如下:

WIN32
_WINDOWS
NDEBUG
CAFFE_VERSION=1.0.0
BOOST_ALL_NO_LIB
USE_LMDB
USE_LEVELDB
USE_CUDNN
USE_OPENCV
CMAKE_WINDOWS_BUILD
GLOG_NO_ABBREVIATED_SEVERITIES
GOOGLE_GLOG_DLL_DECL=__declspec(dllimport)
GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS=__declspec(dllimport)
H5_BUILT_AS_DYNAMIC_LIB=1
CMAKE_INTDIR="Release"

(3)“链接器” –>”输入” –>“附加依赖项”

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
D:Projectscaffe_gpucaffeuildinstalllibcaffe.lib
D:Projectscaffe_gpucaffeuildinstalllibcaffeproto.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesliboost_system-vc140-mt-1_61.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesliboost_thread-vc140-mt-1_61.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesliboost_filesystem-vc140-mt-1_61.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librarieslibglog.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesLibgflags.lib
shlwapi.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesliblibprotobuf.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librarieslibcaffehdf5_hl.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librarieslibcaffehdf5.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariescmake..libcaffezlib.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesliblmdb.lib
ntdll.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librarieslibleveldb.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariescmake..liboost_date_time-vc140-mt-1_61.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariescmake..liboost_filesystem-vc140-mt-1_61.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariescmake..liboost_system-vc140-mt-1_61.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librarieslibsnappy_static.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librarieslibcaffezlib.lib
C:Program FilesNVIDIA GPU Computing ToolkitCUDAv8.0libx64cudart.lib
C:Program FilesNVIDIA GPU Computing ToolkitCUDAv8.0libx64curand.lib
C:Program FilesNVIDIA GPU Computing ToolkitCUDAv8.0libx64cublas.lib
C:Program FilesNVIDIA GPU Computing ToolkitCUDAv8.0libx64cudnn.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesx64vc14libopencv_highgui310.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesx64vc14libopencv_imgcodecs310.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesx64vc14libopencv_imgproc310.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesx64vc14libopencv_core310.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesliblibopenblas.dll.a
C:Users	ingpanAppDataLocalProgramsPythonPython35libspython35.lib
C:Users	ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesliboost_python-vc140-mt-1_61.lib

去掉勾选 “从父级或项目默认设置继承”。其中tingpan改成自己电脑的用户名。

(4)将D:Projectscaffe_gpucaffeuildinstallin添加到环境变量。

5、编译

如果出现一些错误,提示缺少dll库文件,则从C:Users ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesx64vc14in或C:Users ingpan.caffedependencieslibraries_v140_x64_py35_1.1.0librariesin中拷贝对应的dll文件到D:Projectscaffe_gpucaffeuildinstallin目录下。

6、测试

参数输入:

model/deploy_gender2.prototxt model/gender_net.caffemodel model/deploy_age2.prototxt model/age_net.caffemodel model/mean.binaryproto img/0008.jpg

输出结果如下:

技术分享图片

技术分享图片


以上是关于caffe实现年龄及性别预测的主要内容,如果未能解决你的问题,请参考以下文章

Excel项目实战-根据父母的购买行为来预测儿童的年龄,或者根据孩子的信息(年龄,性别等)来预测用户会购买哪种商品。

Excel项目实战-根据父母的购买行为来预测儿童的年龄,或者根据孩子的信息(年龄,性别等)来预测用户会购买哪种商品。

使用 OpenCV 进行图像中的性别预测和年龄检测

逻辑回归算法的原理及实现(LR)

逻辑回归算法的原理及实现(LR)

如何利用身份证号码计算出生年月,年龄及性别