Caffe and Python implementation of Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks.
Set up environment and copy C++ layer code to Caffe's source code tree.
$ export PYTHONPATH=/path/to/Joint-Face-Detection-and-Alignment:$PYTHONPATH
$ export CAFFE_HOME=/path/to/caffe
$ sh layers/copy.sh
Compile Caffe following its document.
Download dataset WIDER, CelebA and FDDB. Put them in data directory like below.
data
├── CelebA
│ └── img_celeba
├── fddb
│ ├── FDDB-folds
│ ├── images
│ │ ├── 2002
│ │ └── 2003
│ └── result
│ └── images
└── WIDER
├── wider_face_split
├── WIDER_test
├── WIDER_train
└── WIDER_val
I have write a matlab script to extract WIDER FACE info from matlab mat
file to txt
file.
Prepare data and train network follow the commands in train.sh
.
Test the model with demo.py
for simple detection and fddb.py
for FDDB benchmark.
Since pNet
may output many bboxes for rNet
and Caffe's Blob
never realloc the memory if your new data is smaller, this makes Blob
only grow the memory and never reduce, which looks like a memory leak. It is fine for most cases but not for our case. You may modify src/caffe/blob.cpp
if you encounter the memory issue.
template <typename Dtype>
void Blob<Dtype>::Reshape(const vector<int>& shape) {
/* some code */
if (count_ > capacity_) { // never reduce the memory here
capacity_ = count_;
data_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
diff_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
}
}
template <typename Dtype>
void Blob<Dtype>::Reshape(const vector<int>& shape) {
/* some code */
if (count_ != capacity_) { // make a new data buffer
capacity_ = count_;
data_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
diff_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
}
}