• Stars
    star
    101
  • Rank 336,171 (Top 7 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 8 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

$ 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.

Prepare data

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.

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.

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)));
  }
}

References