VGG深度网络实现人脸特征点预测与人脸pose(3D
)估计
一、实现需要的库:
- caffe
- dlib face detector
you can down dlib18.17
cd your dlib folder
cd python_example
./compile_dlib_python_module.bat
add dlib.so to the python path
if using dlib18.18, you can follow the official instruction
- opencv
python landmarkPredict.py predictImage testList.txt
三、参数说明:
testList.txt: 图片路径
如下:
img/image_09.jpg
img/image_018.jpg
img/image_019_1.jpg
img/image_020_1.jpg
img/image_018.jpg
img/image_019_1.jpg
img/image_020_1.jpg
四、训练好的模型:
点击这里下载: here
五、*.prototxt 文件预览
name: "dlib_vgg"
layers {
name: "data"
type: MEMORY_DATA
top: "data"
top: "label"
memory_data_param {
batch_size: 1 #batch size, so how many prediction youu want to do at once. Best is "1", but higher number get better performance
channels: 3
height: 224
width: 224
}
}
layers {
bottom: "data"
top: "conv1"
name: "conv1"
type: CONVOLUTION
convolution_param {
num_output: 96
kernel_size: 7
stride: 2
}
}
layers {
bottom: "conv1"
top: "conv1"
name: "relu1"
type: RELU
}
layers {
bottom: "conv1"
top: "norm1"
name: "norm1"
type: LRN
lrn_param {
local_size: 5
alpha: 0.0005
beta: 0.75
k: 2
}
}
layers {
bottom: "norm1"
top: "pool1"
name: "pool1"
type: POOLING
pooling_param {
pool: MAX
kernel_size: 3
stride: 3
}
}
layers {
bottom: "pool1"
top: "conv2"
name: "conv2"
type: CONVOLUTION
convolution_param {
num_output: 256
kernel_size: 5
}
}
layers {
bottom: "conv2"
top: "conv2"
name: "relu2"
type: RELU
}
layers {
bottom: "conv2"
top: "pool2"
name: "pool2"
type: POOLING
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layers {
bottom: "pool2"
top: "conv3"
name: "conv3"
type: CONVOLUTION
convolution_param {
num_output: 512
pad: 1
kernel_size: 3
}
}
layers {
bottom: "conv3"
top: "conv3"
name: "relu3"
type: RELU
}
layers {
bottom: "conv3"
top: "conv4"
name: "conv4"
type: CONVOLUTION
convolution_param {
num_output: 512
pad: 1
kernel_size: 3
}
}
layers {
bottom: "conv4"
top: "conv4"
name: "relu4"
type: RELU
}
layers {
bottom: "conv4"
top: "conv5"
name: "conv5"
type: CONVOLUTION
convolution_param {
num_output: 512
pad: 1
kernel_size: 3
}
}
layers {
bottom: "conv5"
top: "conv5"
name: "relu5"
type: RELU
}
layers {
bottom: "conv5"
top: "pool5"
name: "pool5"
type: POOLING
pooling_param {
pool: MAX
kernel_size: 3
stride: 3
}
}
layers {
bottom: "pool5"
top: "fc6"
name: "fc6"
type: INNER_PRODUCT
inner_product_param {
num_output: 4096
}
}
layers {
bottom: "fc6"
top: "fc6"
name: "relu6"
type: RELU
}
layers {
bottom: "fc6"
top: "fc6"
name: "drop6"
type: DROPOUT
dropout_param {
dropout_ratio: 0.5
}
}
layers {
bottom: "fc6"
top: "fc7"
name: "fc7"
type: INNER_PRODUCT
inner_product_param {
num_output: 4096
}
}
layers {
bottom: "fc7"
top: "fc7"
name: "relu7"
type: RELU
}
layers {
bottom: "fc7"
top: "fc7"
name: "drop7"
type: DROPOUT
dropout_param {
dropout_ratio: 0.5
}
}
layers {
bottom: "fc7"
top: "68point"
name: "68point"
type: INNER_PRODUCT
inner_product_param {
num_output: 136
}
}
layers {
bottom: "fc7"
top: "poselayer"
name: "poselayer"
type: INNER_PRODUCT
inner_product_param {
num_output: 3
}
}
实验效果:
代码下载: