论文: Sun Y, Wang X, Tang X. Deep learning face representation from predicting 10,000 classes[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2014: 1891-1898.
This paper proposes to learn a set of high-level feature representations through deep learning, referred to as Deep hidden IDentity features (DeepID), for face verification. We argue that DeepID can be effectively learned through challenging multi-class face identification tasks, whilst they can be generalized to other tasks (such as verification) and new identities unseen in the training set. Moreover, the generalization capability of DeepID increases as more face classes are to be predicted at training. DeepID features are taken from the last hidden layer neuron activations of deep convolutional networks (ConvNets). When learned as classifiers to recognize about 10; 000 face identities in the training set and configured to keep reducing the neuron numbers along the feature extraction hierarchy, these deep ConvNets gradually form compact identity-related features in the top layers with only a small number of hidden neurons. The proposed features are extracted from various face regions to form complementary and over-complete mrepresentations. Any state-of-the-art classifiers can be learned based on these high-level representations for face verification. 97:45% verification accuracy on LFW is achieved with only weakly aligned faces.
The data set contains 3,425 videos of 1,595 different people. All the videos were downloaded from YouTube. An average of 2.15 videos are available for each subject. The shortest clip duration is 48 frames, the longest clip is 6,070 frames, and the average length of a video clip is 181.3 frames.
Used to get the face out of the img. Face in youtube data has been aligned into the center of the img. So this programme aims to increase the ratio of the face in the whole img and resize the img into (47,55), which is the input size for the DeepID.
cd ./src
Change the aligned_db_folder and result_folder in crop.py.
python crop.py
After cropping images, change src_folder in split.py and split data into two set, One is for train and one is for valid.
python split.py
.
└─ DeepID
├── ascend310_infer // 310 infer directory
├─ README.md // Descriptions about DeepID
├─ scripts
├─ run_standalone_train_ascend.sh // Train standalone
├─ run_distribute_train_ascend.sh // Train distribute
├─ run_eval_ascend.sh // Evaluation
├─ run_infer_310.sh // 310 inference
├─ eval_ascend.sh // Evaluation
├─ run_standalone_train_gpu.sh // Train standalone
├─ run_distribute_train_gpu.sh // Train distribute
└─ eval_gpu.sh // Evaluation
├─src
├─ dataset.py // Prepare dataset
├─ loss.py // Loss function
├─ model.py // Define subnetwork about DeepID
├─ util.py // Utils for DeepID
├─ reporter.py // Reporter class
├─ cell.py // StarGAN model define
├─ crop.py // Crop images
├─ split.py // Split train and valid dataset
├─ eval.py // Evaluation script
├─ train.py // Train script
├─ export.py // Export mindir script
├─ preprocess.py // Convert images and labels to bin
├─ postprocess.py // Calculate accuracy
'data_url':'./data/' # Dataset path
'epochs':200 # Total epochs
'lr':1e-4 # Learning rate
'batch_size':2048 # Batch size
'input_dim':125 # Image dim
'ckpt_path':'' # Checkpoint saving path
'run_distribute':0 # Run distribute, default: 0
'device_target':'Ascend' # Device target
'device_id':4 # Device id, default: 0
'device_num':1 # Number of device, default: 1
'rank_id':0 # Rank id, default: 0
'modelarts':0 # Running on modelarts
'train_url':'None' # Train output path in modelarts
After installing MindSpore, follow these steps:
Train on Ascend
# train standalone
bash run_standalone_train_ascend.sh [DEVICE_NUM] [DEVICE_ID]
# train distribute
bash run_distribute_train.sh [DEVICE_NUM] [DISTRIBUTE] [RANK_TABLE_FILE]
Train on GPU
# train standalone
bash run_standalone_train_gpu.sh [DEVICE_ID] [DATA_DIR]
for example: bash run_standalone_train_gpu.sh 0 ./data
# train distribute
bash run_distribute_train_gpu.sh [DEVICE_NUM] [CUDA_VISIBLE_DEVICES(0,1,2,3,4,5,6,7)] [DATA_DIR]
for example: bash run_distribute_train_gpu.sh 8 0,1,2,3,4,5,6,7 /home/DeepID/data
Eval on Ascend
# Evaluation on Ascend
sh eval_ascend.sh [DEVICE_NUM] [DEVICE_ID]
Before inference, please refer to MindSpore Inference with C++ Deployment Guide to set environment variables.
python export.py
cd scripts
bash run_infer_310.sh [MINDIR_PATH] [DATA_PATH] [DEVICE_ID]
MINDIR_PATH
Directionary of MINDIRDATA_PATH
Directionary of datasetDEVICE_ID
Optional, default 0======= Eval on GPU
# Evaluation on GPU
bash eval_gpu.sh [DEVICE_ID] [CHECKPOINTPATH] [DATA_DIR] [MODE(valid,test)]
for example: bash eval_gpu.sh 0 /home/DeepID.ckpt /home/DeepID/data valid
The evaluation results will be saved in the sample path in a log file named "log_eval.txt". You can find results similar to the following in the log.
Valid dataset accuracy: 0.9683
Parameters | Ascend 910 | GPU |
---|---|---|
Model Version | DeepID | DeepID |
Resource | Ascend | GPU |
uploaded Date | 11/04/2021 (month/day/year) | 11/18/2021 |
MindSpore Version | 1.3.1 | 1.5.0 |
Dataset | Youtube Face | Youtube Face |
Training Parameters | epochs=200, batch_size=1024, lr=0.0001 | epochs=200, batch_size=2048, lr=0.0001 |
Optimizer | Adam | Adam |
outputs | Accuracy = 99.18% | Accuracy = 99.24% |
Speed | 1pc: 900 ms/step; | 1pc: 1250 ms/step 8pc:290 ms/step |
Total time | 1pc: 3h6s; | 1pc: 4:44:52 8pc:0:50:23 |
Parameters (M) | 4.56 M | 4.56 M |
Checkpoint for Fine tuning | 2.03 M (.ckpt file) | 2.03 M (.ckpt file) |
Parameters | Ascend 910 | GPU |
---|---|---|
Model Version | DeepID | DeepID |
Resource | Ascend | GPU |
Uploaded Date | 11/04/2021 (month/day/year) | 11/18/2021 |
MindSpore Version | 1.3.1 | 1.5.0 |
Dataset | Youtube Face | Youtube Face |
batch_size | 512 | 256 |
outputs | Accuracy = 96.83% | Accuracy = 95.05% |
Parameters | Ascend 310 |
---|---|
Model Version | DeepID |
Resource | Ascend |
Uploaded Date | 11/30/2021 (month/day/year) |
MindSpore Version | 1.3.1 |
Dataset | Youtube Face |
batch_size | 1 |
outputs | Accuracy = 96.83% |
Please check the official homepage.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。