mirror of
https://github.com/deepinsight/insightface.git
synced 2026-05-18 22:57:49 +00:00
69 lines
1.9 KiB
Markdown
69 lines
1.9 KiB
Markdown
### Train
|
|
|
|
1. Install `MXNet` with GPU support (Python 2.7).
|
|
|
|
```
|
|
pip install mxnet-cu90
|
|
```
|
|
|
|
2. Clone the InsightFace repository. We call the directory insightface as *`INSIGHTFACE_ROOT`*.
|
|
|
|
```
|
|
git clone --recursive https://github.com/deepinsight/insightface.git
|
|
```
|
|
|
|
3. Download the training set (`MS1M-Arcface`) and place it in *`$INSIGHTFACE_ROOT/datasets/`*. Each training dataset includes at least following 6 files:
|
|
|
|
```Shell
|
|
faces_emore/
|
|
train.idx
|
|
train.rec
|
|
property
|
|
lfw.bin
|
|
cfp_fp.bin
|
|
agedb_30.bin
|
|
```
|
|
|
|
The first three files are the training dataset while the last three files are verification sets.
|
|
|
|
4. Train deep face recognition models.
|
|
In this part, we assume you are in the directory *`$INSIGHTFACE_ROOT/recognition/`*.
|
|
```Shell
|
|
export MXNET_CPU_WORKER_NTHREADS=24
|
|
export MXNET_ENGINE_TYPE=ThreadedEnginePerDevice
|
|
```
|
|
|
|
Place and edit config file:
|
|
```Shell
|
|
cp sample_config.py config.py
|
|
vim config.py # edit dataset path etc..
|
|
```
|
|
|
|
We give some examples below. Our experiments were conducted on the Tesla P40 GPU.
|
|
|
|
(1). Train ArcFace with LResNet100E-IR.
|
|
|
|
```Shell
|
|
CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network r100 --loss arcface --dataset emore
|
|
```
|
|
It will output verification results of *LFW*, *CFP-FP* and *AgeDB-30* every 2000 batches. You can check all options in *config.py*.
|
|
This model can achieve *LFW 99.80+* and *MegaFace 98.3%+*.
|
|
|
|
(2). Train CosineFace with LResNet50E-IR.
|
|
|
|
```Shell
|
|
CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network r50 --loss cosface --dataset emore
|
|
```
|
|
|
|
(3). Train Softmax with LMobileNet-GAP.
|
|
|
|
```Shell
|
|
CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network m1 --loss softmax --dataset emore
|
|
```
|
|
|
|
(4). Fine-turn the above Softmax model with Triplet loss.
|
|
|
|
```Shell
|
|
CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network m1 --loss triplet --lr 0.005 --pretrained ./models/m1-softmax-emore,1
|
|
```
|