Skip to content

Instantly share code, notes, and snippets.

@ishay2b
Last active March 30, 2019 23:55
Show Gist options
  • Save ishay2b/58248e5f3c3bf575ac40 to your computer and use it in GitHub Desktop.
Save ishay2b/58248e5f3c3bf575ac40 to your computer and use it in GitHub Desktop.
Vanilla CNN caffe model
name caffemodel caffemodel_url license sha1 caffe_commit
Vanilla CNN Model
vanillaCNN.caffemodel
unrestricted
b5e34ce75d078025e07452cb47e65d198fe27912
9c9f94e18a8909580a6b94c44dbb1e46f0ee8eb8

Implementation of the Vanilla CNN described in the paper: Yue Wu and Tal Hassner, "Facial Landmark Detection with Tweaked Convolutional Neural Networks", arXiv preprint arXiv:1511.04031, 12 Nov. 2015. See project page for more information about this project. http://www.openu.ac.il/home/hassner/projects/tcnn_landmarks/

Written by Ishay Tubi: https://www.linkedin.com/in/ishay2b

This software is provided as is, without any warranty, with no legal constraints.

See github repository: http://bit.ly/1SbTqTf

The bundled model is the iteration 1,000,000 snapshot using vanilla_adam_solver.prototxt

Model was traind using AFLW train data, and obtains a 7.6% mean error for AFW benchmark and 8.3% for AFLW benchmark.

License

This model is released for unrestricted use.

# The train/test net protocol buffer definition
# this follows "ADAM: A METHOD FOR STOCHASTIC OPTIMIZATION"
net: "vanilla_train.prototxt"
type: "Adam"
test_iter: 1000
test_interval: 5000
base_lr: 0.00001
momentum: 0.9
momentum2: 0.999
# since Adam dynamically changes the learning rate, we set the base learning
# rate to a fixed value
lr_policy: "fixed"
# Display every 1000 iterations
display: 2500
# The maximum number of iterations
max_iter: 1400000
# snapshot intermediate results
snapshot: 5000
snapshot_prefix: "../caffeData/snapshots/snap"
# solver mode: CPU or GPU
solver_mode: CPU
name: "vanila"
input: "data"
input_dim: 1
input_dim: 3
input_dim: 40
input_dim: 40
########################################
# the actual net
# layer 1
layer {
name: "Conv1"
type: "Convolution"
bottom: "data"
top: "Conv1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 16
pad: 2
kernel_size: 5
stride: 1
weight_filler {
type: "xavier"
std: 0.1
}
bias_filler {
type: "constant"
value: 0.2
}
}
}
layer {
name: "ActivationTangH1"
bottom: "Conv1"
top: "ActivationTangH1"
type: "TanH"
}
layer {
name: "ActivationAbs1"
bottom: "ActivationTangH1"
top: "Abs1"
type: "AbsVal"
}
layer {
name: "Pool1"
type: "Pooling"
bottom: "Abs1"
top: "Pool1"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "Conv2"
type: "Convolution"
bottom: "Pool1"
top: "Conv2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 48
pad: 1
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
std: 0.1
}
bias_filler {
type: "constant"
value: 0.2
}
}
}
layer {
name: "ActivationTangH2"
bottom: "Conv2"
top: "ActivationTangH2"
type: "TanH"
}
layer {
name: "ActivationAbs2"
bottom: "ActivationTangH2"
top: "Abs2"
type: "AbsVal"
}
layer {
name: "Pool2"
type: "Pooling"
bottom: "Abs2"
top: "Pool2"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
# layer 3
layer {
name: "Conv3"
type: "Convolution"
bottom: "Pool2"
top: "Conv3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
pad: 0
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
std: 0.1
}
bias_filler {
type: "constant"
value: 0.2
}
}
}
layer {
name: "ActivationTangH3"
bottom: "Conv3"
top: "ActivationTangH3"
type: "TanH"
}
layer {
name: "ActivationAbs3"
bottom: "ActivationTangH3"
top: "Abs3"
type: "AbsVal"
}
layer {
name: "Pool3"
type: "Pooling"
bottom: "Abs3"
top: "Pool3"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
# layer 4
layer {
name: "Conv4"
type: "Convolution"
bottom: "Pool3"
top: "Conv4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
pad: 0
kernel_size: 2
stride: 1
weight_filler {
type: "xavier"
std: 0.1
}
bias_filler {
type: "constant"
value: 0.2
}
}
}
layer {
name: "ActivationTangH4"
bottom: "Conv4"
top: "ActivationTangH4"
type: "TanH"
}
layer {
name: "ActivationAbs4"
bottom: "ActivationTangH4"
top: "Abs4"
type: "AbsVal"
}
########################################
layer {
name: "Dense1"
type: "InnerProduct"
bottom: "Abs4"
top: "Dense1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 100
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "ActivationTangH5"
bottom: "Dense1"
top: "ActivationTangH5"
type: "TanH"
}
layer {
name: "ActivationAbs5"
bottom: "ActivationTangH5"
top: "Abs5"
type: "AbsVal"
}
layer {
name: "Dense2"
type: "InnerProduct"
bottom: "Abs5"
top: "Dense2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 10
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
name: "vanila"
layer {
type: "HDF5Data"
top: "X" # same name as given in create_dataset!
top: "landmarks"
hdf5_data_param {
source: "/Users/ishay/Dev/VanilaCNN/caffeData/train.txt" # do not give the h5 files directly, but the list.
batch_size: 30
}
include { phase:TRAIN }
}
layer {
type: "HDF5Data"
top: "X" # same name as given in create_dataset!
top: "landmarks"
hdf5_data_param {
source: "/Users/ishay/Dev/VanilaCNN/caffeData/test.txt" # do not give the h5 files directly, but the list.
batch_size: 10
}
include { phase:TEST }
}
layer {
name: "Conv1"
type: "Convolution"
bottom: "X"
top: "Conv1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 16
pad: 2
kernel_size: 5
stride: 1
weight_filler {
type: "xavier"
std: 0.1
}
bias_filler {
type: "constant"
value: 0.2
}
}
}
layer {
name: "ActivationTangH1"
bottom: "Conv1"
top: "ActivationTangH1"
type: "TanH"
}
layer {
name: "ActivationAbs1"
bottom: "ActivationTangH1"
top: "Abs1"
type: "AbsVal"
}
layer {
name: "Pool1"
type: "Pooling"
bottom: "Abs1"
top: "Pool1"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "Conv2"
type: "Convolution"
bottom: "Pool1"
top: "Conv2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 48
pad: 1
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
std: 0.1
}
bias_filler {
type: "constant"
value: 0.2
}
}
}
layer {
name: "ActivationTangH2"
bottom: "Conv2"
top: "ActivationTangH2"
type: "TanH"
}
layer {
name: "ActivationAbs2"
bottom: "ActivationTangH2"
top: "Abs2"
type: "AbsVal"
}
layer {
name: "Pool2"
type: "Pooling"
bottom: "Abs2"
top: "Pool2"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
# layer 3
layer {
name: "Conv3"
type: "Convolution"
bottom: "Pool2"
top: "Conv3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
pad: 0
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
std: 0.1
}
bias_filler {
type: "constant"
value: 0.2
}
}
}
layer {
name: "ActivationTangH3"
bottom: "Conv3"
top: "ActivationTangH3"
type: "TanH"
}
layer {
name: "ActivationAbs3"
bottom: "ActivationTangH3"
top: "Abs3"
type: "AbsVal"
}
layer {
name: "Pool3"
type: "Pooling"
bottom: "Abs3"
top: "Pool3"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
# layer 4
layer {
name: "Conv4"
type: "Convolution"
bottom: "Pool3"
top: "Conv4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
pad: 0
kernel_size: 2
stride: 1
weight_filler {
type: "xavier"
std: 0.1
}
bias_filler {
type: "constant"
value: 0.2
}
}
}
layer {
name: "ActivationTangH4"
bottom: "Conv4"
top: "ActivationTangH4"
type: "TanH"
}
layer {
name: "ActivationAbs4"
bottom: "ActivationTangH4"
top: "Abs4"
type: "AbsVal"
}
########################################
layer {
name: "Dense1"
type: "InnerProduct"
bottom: "Abs4"
top: "Dense1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 100
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "ActivationTangH5"
bottom: "Dense1"
top: "ActivationTangH5"
type: "TanH"
}
layer {
name: "ActivationAbs5"
bottom: "ActivationTangH5"
top: "Abs5"
type: "AbsVal"
}
layer {
name: "Dense2"
type: "InnerProduct"
bottom: "Abs5"
top: "Dense2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 10
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
type: 'Python'
name: 'loss'
top: 'loss'
bottom: 'Dense2'
bottom: 'landmarks'
python_param {
# the module name -- usually the filename -- that needs to be in $PYTHONPATH
module: 'python.NormlizedMSE'
# the layer name -- the class name in the module
layer: 'NormlizedMSE'
}
# set loss weight so Caffe knows this is a loss layer.
# since PythonLayer inherits directly from Layer, this isn't automatically
# known to Caffe
loss_weight: 1
}
@nanoart
Copy link

nanoart commented Mar 31, 2016

Hi,

I tried to get the model with ./scripts/download_model_from_gist.sh <gist_id>, but the result is a html file instead, not a zip file.

Can you please fix this problem? although I can get the model from your github project.

@sohaib730
Copy link

In your paper, it's mentioned TCDCN can be used to detect more than 5 Landmark points. But i can't find trained model weights or deploy.prototxt for that purpose. Can you please redirect me to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment