English | 简体中文
[TOC]
An implementation of the face (emotion and gender) classification models (MiniXception
。SimpleCNN
) proposed in paper Real-time Convolutional Neural Networks for Emotion and Gender Classification
with PaddlePaddle. SimpleCNN
is a standard fully-convolutional neural network composed of 9 convolution layers, ReLUs, Batch Normalization and Global Average Pooling. MiniXception
replaces the convolution layers with depth-wise separable convolutions and residual modules.
We trained the models with imdb_crop
dataset in gender classification task and each model obtains an accuracy of 96%.
Model | Accuracy | Input shape |
---|---|---|
SimpleCNN | 96.00% | (48, 48, 3) |
MiniXception | 96.01% | (64, 64, 1) |
We trained and tested models on dataset imdb_crop (the password is mu2h
). The dataset can be also download from here. First, download and uncompress the dataset. Then, edit configuration files config/simple_conf.yaml
and config/min_conf.yaml
of models SimpleCNN
and MiniXception
. Set imdb_dir
to be the path to the dataset. imdb_dir
s should be the same in training and test stages. You don't need to split the dataset into training and test set, because the python scripts will do that. The dataset will be split in the manner of that proposed in the paper. That is, sorts the images by file names and considers the front 80% as training set and the rear 20% as test set.
scipy==1.2.1
paddlepaddle==2.1.2
numpy==1.20.1
opencv-python==3.4.10.37
pyyaml~=5.4.1
visualdl~=2.2.0
tqdm~=4.62.0
# clone this repo
git clone https://github.com/wapping/FaceClassification.git
cd FaceClassification
Edit the configuration file for your own and run the command like
python train.py -c path_to_conf
For example
python train.py -c ./config/simple_conf.yaml
Edit the configuration file for your own and run the command like
python eval.py -c path_to_conf
Just wait for the results.
|____config
| |____conf.yaml
| |____confg.py
| |____simple_conf.yaml
| |____mini_conf.yaml
|____data
| |____dataset.py
|____models
| |____simple_cnn.py
| |____mini_xception.py
|____train.py
|____eval.py
-
train.py
--conf_path
: optional, the path to the configuration file,config/conf.yaml
by default.--model_name
: optional, the model name. If given, it will replacemodel name
in the configuration file. -
eval.py
--conf_path
: optional, the path to the configuration file,config/conf.yaml
by default.--model_name
: optional, the model name. If given, it will replacemodel name
in the configuration file.--model_state_dict
: optional, the path to the model. If given, it will replacemodel_state_dict
in the configuration file.
Field | Content |
---|---|
Author | Huaping Li、Xiaoqian Song |
Date | 2021.09 |
Framework version | paddlepaddle 2.1.2 |
Application scenarios | Face classification |
Supported hardware | CPU、GPU |