项目作者: luoyetx

项目描述 :
Caffe and Python implementation of Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks
高级语言: Python
项目地址: git://github.com/luoyetx/Joint-Face-Detection-and-Alignment.git
创建时间: 2016-06-15T08:42:03Z
项目社区:https://github.com/luoyetx/Joint-Face-Detection-and-Alignment

开源协议:Other

下载


Joint-Face-Detection-and-Alignment

Caffe and Python implementation of Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks.

Set up

Set up environment and copy C++ layer code to Caffe’s source code tree.

  1. $ export PYTHONPATH=/path/to/Joint-Face-Detection-and-Alignment:$PYTHONPATH
  2. $ export CAFFE_HOME=/path/to/caffe
  3. $ sh layers/copy.sh

Compile Caffe following its document.

Prepare data

Download dataset WIDER, CelebA and FDDB. Put them in data directory like below.

  1. data
  2. ├── CelebA
  3. └── img_celeba
  4. ├── fddb
  5. ├── FDDB-folds
  6. ├── images
  7. ├── 2002
  8. └── 2003
  9. └── result
  10. └── images
  11. └── WIDER
  12. ├── wider_face_split
  13. ├── WIDER_test
  14. ├── WIDER_train
  15. └── WIDER_val

I have write a matlab script to extract WIDER FACE info from matlab mat file to txt file.

Train

Prepare data and train network follow the commands in train.sh.

Test

Test the model with demo.py for simple detection and fddb.py for FDDB benchmark.

Memory Issue

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.

  1. template <typename Dtype>
  2. void Blob<Dtype>::Reshape(const vector<int>& shape) {
  3. /* some code */
  4. if (count_ > capacity_) { // never reduce the memory here
  5. capacity_ = count_;
  6. data_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
  7. diff_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
  8. }
  9. }
  1. template <typename Dtype>
  2. void Blob<Dtype>::Reshape(const vector<int>& shape) {
  3. /* some code */
  4. if (count_ != capacity_) { // make a new data buffer
  5. capacity_ = count_;
  6. data_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
  7. diff_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
  8. }
  9. }

References