|
2 年之前 | |
---|---|---|
detectors | 2 年之前 | |
loss | 2 年之前 | |
models | 2 年之前 | |
optimizer | 2 年之前 | |
scheduler | 2 年之前 | |
.gitignore | 2 年之前 | |
DatasetLoader.py | 2 年之前 | |
EmbedNet.py | 2 年之前 | |
LICENSE.md | 2 年之前 | |
README.md | 2 年之前 | |
client.py | 2 年之前 | |
requirements.txt | 2 年之前 | |
server.py | 2 年之前 | |
trainEmbedNet.py | 2 年之前 | |
utils.py | 2 年之前 |
This repository contains the framework for training deep embeddings for face recognition. The trainer is intended for the face recognition exercise of the Machine Learning for Visual Understanding course, but the flexible code can be used for any meta-learning task. This is an adaptation of the speaker recognition model trainer described in In defence of metric learning for speaker recognition.
pip install -r requirements.txt
AM-Softmax:
python ./trainEmbedNet.py --model ResNet18 --trainfunc amsoftmax --save_path exps/exp1 --nClasses 2622 --batch_size 200 --scale 30 --margin 0.2
Angular prototypical:
python ./trainEmbedNet.py --model ResNet18 --trainfunc angleproto --save_path exps/exp2 --nPerClass 2 --batch_size 200
The arguments can also be passed as --config path_to_config.yaml
. Note that the configuration file overrides the arguments passed via command line.
Use --mixedprec
flag to enable mixed precision training. This is recommended for Tesla V100, GeForce RTX 20 series or later models.
Softmax (softmax)
AM-Softmax (amsoftmax)
AAM-Softmax (aamsoftmax)
GE2E (ge2e)
Prototypical (proto)
Triplet (triplet)
Angular Prototypical (angleproto)
Angular Prototypical + Softmax (softmaxproto)
For softmax-based losses, nPerClass
should be 1, and nClasses
must be specified. For metric-based losses, nPerClass
should be 2 or more. For softmaxproto
, nPerClass
should be 2 and nClasses
must also be specified.
ResNet18
ResNeXt50
You can add new models and loss functions to models
and loss
directories respectively. See the existing definitions for examples.
The test list should contain labels and image pairs, one line per pair, as follows. 1
is a target and 0
is an imposter.
1,id10001/00001.jpg,id10001/00002.jpg
0,id10001/00003.jpg,id10002/00001.jpg
The folders in the training set should contain images for each identity (i.e. identity/image.jpg
).
The input transformations can be changed in the code.
Please cite the following if you make use of the code.
@inproceedings{chung2020in,
title={In defence of metric learning for speaker recognition},
author={Chung, Joon Son and Huh, Jaesung and Mun, Seongkyu and Lee, Minjae and Heo, Hee Soo and Choe, Soyeon and Ham, Chiheon and Jung, Sunghwan and Lee, Bong-Jin and Han, Icksang},
booktitle={Interspeech},
year={2020}
}
python ./server.py
Copyright (c) 2020-present Joon Son Chung.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.