码迷,mamicode.com
首页 > 其他好文 > 详细

caffe实现年龄及性别预测

时间:2018-08-01 01:06:07      阅读:469      评论:0      收藏:0      [点我收藏+]

标签:拷贝   add   open   www   amp   cuda   via   log   lib   

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

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:\Projects\caffe_gpu\caffe\build\include
D:\Projects\caffe_gpu\caffe\build
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\include\boost-1_61
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\include
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\include\opencv
D:\Projects\caffe_gpu\caffe\include
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\Include

其中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:\Projects\caffe_gpu\caffe\build\install\lib\caffe.lib
D:\Projects\caffe_gpu\caffe\build\install\lib\caffeproto.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\boost_system-vc140-mt-1_61.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\boost_thread-vc140-mt-1_61.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\boost_filesystem-vc140-mt-1_61.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\glog.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\Lib\gflags.lib
shlwapi.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\libprotobuf.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\caffehdf5_hl.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\caffehdf5.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\cmake\..\lib\caffezlib.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\lmdb.lib
ntdll.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\leveldb.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\cmake\..\lib\boost_date_time-vc140-mt-1_61.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\cmake\..\lib\boost_filesystem-vc140-mt-1_61.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\cmake\..\lib\boost_system-vc140-mt-1_61.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\snappy_static.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\caffezlib.lib
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64\cudart.lib
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64\curand.lib
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64\cublas.lib
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64\cudnn.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\x64\vc14\lib\opencv_highgui310.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\x64\vc14\lib\opencv_imgcodecs310.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\x64\vc14\lib\opencv_imgproc310.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\x64\vc14\lib\opencv_core310.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\libopenblas.dll.a
C:\Users\tingpan\AppData\Local\Programs\Python\Python35\libs\python35.lib
C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib\boost_python-vc140-mt-1_61.lib

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

(4)将D:\Projects\caffe_gpu\caffe\build\install\bin添加到环境变量。

5、编译

如果出现一些错误,提示缺少dll库文件,则从C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\x64\vc14\bin\或C:\Users\tingpan\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\bin\中拷贝对应的dll文件到D:\Projects\caffe_gpu\caffe\build\install\bin目录下。

6、测试

参数输入:

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

输出结果如下:

技术分享图片

技术分享图片

caffe实现年龄及性别预测

标签:拷贝   add   open   www   amp   cuda   via   log   lib   

原文地址:https://www.cnblogs.com/smbx-ztbz/p/9399016.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!