Coder Social home page Coder Social logo

garricklin / jda Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luoyetx/jda

0.0 2.0 0.0 185 KB

C++ implementation of Joint Cascade Face Detection and Alignment.

License: BSD 3-Clause "New" or "Revised" License

CMake 1.06% C++ 95.08% Python 3.86%

jda's Introduction

JDA

C++ implementation of Joint Cascade Face Detection and Alignment.

Fetech Code

I recommend using Git to fetch the source code. If you are not familiar with Git, there is a tutorial you can follow.

$ git clone --recursive https://github.com/luoyetx/JDA.git

OR

$ git clone https://github.com/luoyetx/JDA.git
$ cd JDA
$ git submodule update --init

If you directly download the zip file, please remember to download luoyetx/liblinear and luoyetx/jsmnpp, then extract the source code to 3rdparty. liblinear is used for global regression training and jsmnpp is used for json config parsing.

Build

We use CMake to build the project, I highly recommend you to use this build tool. We also need OpenCV. If you are on Windows, make sure you have set environment variable OpenCV_DIR to OpenCV's build directory like D:/3rdparty/opencv2.4.11/build. You may also need Visual Studio to compile the source code. If you are on Linux or Unix, install the development packages of OpenCV via your system's Package Manager like apt-get on Ubuntu or yum on CentOS. However, Compile the source code of OpenCV will be the best choice of all.

$ cd JDA
$ mkdir build && cd build
$ cmake ..
$ make

Config

We use config.json for configuration. config.template.json is a template, please copy one and rename it to config.json. Attention, all relative path is start from build directory, and please use / instead of \\ even if you are on Windows platform.

Data

You should prepare your own data. You need two kinds of data, face with landmarks and background images. You also need to create two text file face.txt and background.txt which can be changed in config.json. Every line of face.txt indicates a face image's path with its landmarks. The number of landmarks can be changed in config.json and the order of landmarks does not matter.

../data/face/00001.jpg x1 y1 x2 y2 ........
../data/face/00002.jpg x1 y1 x2 y2 ........
....
....

The face images should be resized to the pre-defined size and you should do any data augmentation by yourself, the code will exactly use the face images you provide. background.txt is much more simpler. Every line indicates where the background image in the file system.

../data/bg/000001.jpg
../data/bg/000002.jpg
../data/bg/000003.jpg
....
....

Background images should have no face and we will do data augmentation during the hard negative mining. Of course, you can use absolute path to indicate where is your face images and background images.

Train

$ ./jda train

If you are using Visual Studio, make sure you know how to pass command line arguments to the program. All trained model file will be saved to model directory.

Model Layout

All model file is saved as a binary file. The model parameters have two data type, 4 byte int and 8 byte double, please pay attention to the endianness of you CPU.

|-- mask (int)
|-- meta
|    |-- T (int)
|    |-- K (int)
|    |-- landmark_n (int)
|    |-- tree_depth (int)
|    |-- current_stage_idx (int) // training status
|    |-- current_cart_idx (int)
|-- mean_shape (double, size = 2*landmark_n)
|-- stages
|    |-- stage_1
|    |    |-- cart_1
|    |    |-- cart_2
|    |    |-- ...
|    |    |-- cart_K
|    |    |-- global regression weight
|    |-- stage_2
|    |-- ...
|    |-- stage_T
|-- mask (int)

For more details of the model file layout, please refer to cascador.cpp and cart.cpp.

FDDB Benchmark

FDDB is widely used for face detection evaluation, download the data and extract to data directory.

|-- data
|    |-- fddb
|         |-- images
|         |    |-- 2002
|         |    |-- 2003
|         |-- FDDB-folds
|         |    |-- FDDB-fold-01.txt
|         |    |-- FDDB-fold-01-ellipseList.txt
|         |    |-- ....
|         |-- result

prepare your data and model file, you also need to set current_stage_idx and current_cart_idx correctly in config.json. All result text file used by npinto/fddb-evaluation is under result directory.

$ ./jda fddb

Attention

It's a shame that I still not get a fully trained model now. There is many detailed problems of JDA algorithm which need to be discussed. My code may have some hidden bugs. Welcome any bug report and any question or idea through the issues.

QQ Group

There is a QQ group 347185749. If you are a Tencent QQ user, welcome to join this group and we can discuss more there.

License

BSD 3-Clause

References

jda's People

Contributors

garricklin avatar luoyetx avatar pletessier avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.