git clone https://github.com/xiao10ma/ANN-hm.git
cd ANN-hm
pip install -r requirements.txt
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
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:
- 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)
- 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)
- 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
Path to the data source directory face data set.
Flag to shuffle dataset.
Path where the trained model should be stored (trained_model/{Modelname}
by default).
Path to the record, you can use tensorboard to visualize it.
Every save_ep epochs, the program will save the trained model. Default 50.
Every save_latest_ep epochs, the program will save the trained model. Default 10.
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