xiao10ma / CNN-Facial-Recognition

人工神经网络课程作业

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Facial Expression Recognition

Installation

git clone https://github.com/xiao10ma/ANN-hm.git
cd ANN-hm
pip install -r requirements.txt

How to run?

Move the data in to the data directory, it looks like this:

data
├── test
│   ├── Angry
│   ├── Happy
│   ├── Neutral
│   ├── Sad
│   └── Surprise
└── train
    ├── Angry
    ├── Happy
    ├── Neutral
    ├── Sad
    └── Surprise

If you are my teaching assistant, you need to copy the 'trained_model' directory from the files I provided into the project directory. The directory structure is as follows:

.
├── data
│   ├── test
│   └── train
├── face_dataset.py
├── model.py
├── net_utils.py
├── output
│   ├── AlexNet
│   ├── ResNet
│   └── VGG
├── README.md
├── requirements.txt
├── trained_model
│   ├── AlexNet
│   ├── ResNet
│   └── VGG
└── train.py

Train

Then, you can run the project with just(default use AlexNet):

python train.py

You can choose different model(AlexNet, VGG, ResNet) in the main function. After that you need to change the record and model path of the args:

  1. AlexNet:
parser.add_argument('--record_path', default='./output/AlexNet/AlexNet-lr_{}epoch_{}'.format(LR, EPOCH), type=str)
parser.add_argument('--model_path', default='./trained_model/AlexNet', type=str)

network = AlexNet().to(device)
  1. VGG:
parser.add_argument('--record_path', default='./output/VGG/VGG-lr_{}epoch_{}'.format(LR, EPOCH), type=str)
parser.add_argument('--model_path', default='./trained_model/VGG', type=str)

network = VGG().to(device)
  1. ResNet:
parser.add_argument('--record_path', default='./output/ResNet/ResNet-lr_{}epoch_{}'.format(LR, EPOCH), type=str)
parser.add_argument('--model_path', default='./trained_model/ResNet', type=str)

network = ResNet50().to(device)

To visualize the training process, you can use tensorboard:

tensorboard --logdir={record_path}
Command Line Arguments for train.py

--data_source / -s

Path to the data source directory face data set.

--random / -m

Flag to shuffle dataset.

--model_path / -m

Path where the trained model should be stored (trained_model/{Modelname} by default).

--record_path

Path to the record, you can use tensorboard to visualize it.

--save_ep

Every save_ep epochs, the program will save the trained model. Default 50.

--save_latest_ep

Every save_latest_ep epochs, the program will save the trained model. Default 10.


Evaluate

I have implemented the evaluation function in train.py; you can call it directly.


If you have any questions, please contact me through email. My email: mazp@mail2.sysu.edu.cn

About

人工神经网络课程作业


Languages

Language:Python 100.0%