• Stars
    star
    339
  • Rank 124,632 (Top 3 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 9 years ago

Reviews

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

Repository Details

Face Alignment by Explicit Shape Regression

###Face Alignment This program is a C++ reimplementation of algorithms in paper "Face Alignment by Explicit Regression" by Cao et al. This program can be used to train models for detecting facial keypoints, and it is extremely fast both in training and testing.

Please go to folder FaceAlignment to see the source files.

###Update

  • Nov 13, 2014 Improve the speed of model training. Now it takes about 40 min to train a model on 1345 images with 20 initial for each on a Core i7 3.40 GHz CPU. Considering no parallel programing is used, this performance is acceptable.

###Usage To compile the program(OpenCV required):

// Go to folder FaceAlignment
cmake .
make TrainDemo.out
make TestDemo.out

To train a new model:

ShapeRegressor regressor;
regressor.Train(images,ground_truth_shapes,bounding_box,first_level_num,second_level_num,
                    candidate_pixel_num,fern_pixel_num,initial_number);
regressor.Save("./data/model.txt");

To predict a new input:

ShapeRegressor regressor;
regressor.load("./data/model_cofw_2.txt");
regressor.Predict(test_images[index],bounding_box[index],initial_number);

For details, please see TrainDemo.cpp and TestDemo.cpp.

###Dataset A public dataset is provided here. The dataset contains 1345 training images, 507 testing images, and each image has 29 landmarks. You can change the path in TrainDemo.cpp and TestDemo.cpp to train new models.

###Model I have prepared a model trained by me on COFW dataset, and you can access it here.

###FAQ

  • How to get the bounding box of an input face image? You can get the bounding box with a face detector, which has been implemented in OpenCV. However, do remember that, if you use the model provided by me, you must provide a bounding box of similar measure with the training data. Otherwise, the result will be poor. If the bounding box of training data is very small, but you provide a very big bounding box for testing data, it is certain that you will get a poor result. Here the same measure doesn't mean that they have to be the same size, but they have to be taken using the same standard, for example, the ratio between bounding box width and the two-eye distance should be the same.

  • It seems that there are still some errors when I do testing, so is there any problem? Generally speaking, the dataset attached is very challenging because it includes heavy occlusions and largeโ€จshape variations. You could try other standard datasets such as Helen and LFW, which should lead to better performance.

  • Format of keypoints.txt and boundingbox.txt? For boundingbox.txt, each row is in the following format, specifying the bounding box of a face in the corresponding image:

x  // x coordinates of top-left corner
y  // y coordinates of top-right corner
width 
height

For keypoints.txt, each row is in the following format, specifying the ground truth of keypoints locations:

x_1 x_2 ... x_N y_1 y_2 ... y_N

###Contact If you have any question about the code, I prefer that you create an issue on GitHub rather than send me emails directly, so that others can also refer to it when they have problems. I will respond to it as soon as possible.

###Sample Results Sample Results

###Reference papers: Face Alignment by Explicit Shape Regression

More Repositories

1

ImageSmoothing

A collection of image smoothing algorithms.
C
154
star
2

L1Flattening

An L1 Image Transform for Edge-Preserving Smoothing and Scene-Level Intrinsic Decomposition
C++
67
star
3

SphericalHarmonics

Compute the spherical harmonic representation of a given environment map
MATLAB
26
star
4

OrthogonalMatchingPursuit

A C++ implementation of orthogonal matching pursuit.
MATLAB
18
star
5

CVPR

This is my code used for pedestrian recognition.
7
star
6

Impressionist

Automatic impressionist style drawing
C++
6
star
7

PersonReidentification

Identify person images taken from non-overlapping cameras
MATLAB
5
star
8

RegExp

Thompson's Construction Algorithm for Regular Expression
Java
5
star
9

Relighting

All frequency relighting
C++
4
star
10

RayTracing

Code for my ray tracing project
C++
3
star
11

Brush

Algorithms for placing brush
C++
2
star
12

TutorialAndroid

Sample codes for learning anroid programming.
Java
2
star
13

SlidesController

Slide controller
Java
1
star
14

CodeGallery

Collection of my code.
C
1
star
15

PPTServer

This is the server part for ppt controller.
Java
1
star
16

FRRR

Idea coming from pfff
Ruby
1
star
17

DailyNotes

My notes for recording daily knowledge learnt.
TeX
1
star
18

soundsilence.github.io

This is my blog.
HTML
1
star
19

PairGame

This is a simple Android App.
Java
1
star
20

SuperPixel

Super pixel generation in MATLAB.
C++
1
star
21

Rdto

Tell me what's important
JavaScript
1
star
22

PPTController

Control slides with your phone.
Java
1
star
23

MusicPlayer

This is a simple music player.
Java
1
star
24

dotvim

Vim configuration and colorscheme
Vim Script
1
star
25

MachineLearning

A collection of my posts written while studying "Pattern recognition and Machine Learning".
CSS
1
star