- [Script and Sample Code](#script-and-sample-code)
- [Running Example](#running-example)
- [Model Description](#model-description)
- [Performance](#performance)
- [ModelZoo Homepage](#modelzoo-homepage)
# [Face Attribute Description](#contents)
This is a Face Attributes Recognition network based on Resnet18, with support for training and evaluation on Ascend910.
ResNet (residual neural network) was proposed by Kaiming He and other four Chinese of Microsoft Research Institute. Through the use of ResNet unit, it successfully trained 152 layers of neural network, and won the championship in ilsvrc2015. The error rate on top 5 was 3.57%, and the parameter quantity was lower than vggnet, so the effect was very outstanding. Traditional convolution network or full connection network will have more or less information loss. At the same time, it will lead to the disappearance or explosion of gradient, which leads to the failure of deep network training. ResNet solves this problem to a certain extent. By passing the input information to the output, the integrity of the information is protected. The whole network only needs to learn the part of the difference between input and output, which simplifies the learning objectives and difficulties.The structure of ResNet can accelerate the training of neural network very quickly, and the accuracy of the model is also greatly improved. At the same time, ResNet is very popular, even can be directly used in the concept net network.
Face Attribute uses a modified-Resnet18 network for performing feature extraction.
# [Dataset](#contents)
This network can recognize the age/gender/mask from a human face. The default rule is:
```python
age:
0: 0~2 years
1: 3~9 years
2: 10~19 years
3: 20~29 years
4: 30~39 years
5: 40~49 years
6: 50~59 years
7: 60~69 years
8: 70+ years
gender:
0: male
1: female
mask:
0: wearing mask
1: without mask
```
We use about 91K face images as training dataset and 11K as evaluating dataset in this example, and you can also use your own datasets or open source datasets (e.g. FairFace and RWMFD)
- step 1: The dataset should be saved in a txt file, which contain the following contents:
The value range of [LABEL_AGE] is [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8], -1 means the label should be ignored.
The value range of [LABEL_GENDER] is [-1, 0, 1], -1 means the label should be ignored.
The value range of [LABEL_MASK] is [-1, 0, 1], -1 means the label should be ignored.
- step 2: Convert the dataset to mindrecord:
```bash
python src/data_to_mindrecord_train.py
```
or
```bash
python src/data_to_mindrecord_eval.py
```
If your dataset is too big to convert at a time, you can add data to an existed mindrecord in turn:
```bash
python src/data_to_mindrecord_train_append.py
```
# [Environment Requirements](#contents)
- Hardware(Ascend)
- Prepare hardware environment with Ascend processor. If you want to try Ascend, please send the [application form](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/file/other/Ascend%20Model%20Zoo%E4%BD%93%E9%AA%8C%E8%B5%84%E6%BA%90%E7%94%B3%E8%AF%B7%E8%A1%A8.docx) to ascend@huawei.com. Once approved, you can get the resources.