thufuturelab / gluon-face Goto Github PK
View Code? Open in Web Editor NEWAn unofficial Gluon FR Toolkit for face recognition. https://gluon-face.readthedocs.io
License: MIT License
An unofficial Gluon FR Toolkit for face recognition. https://gluon-face.readthedocs.io
License: MIT License
We have a good time when writing this and I still love this project. We seem to have done a awesome thing.
But for some irresistible cause we may hard to update this.
This project is still could be used for some time so don't worry.
We sincerely thank for all of contributors and people who love this.
I may contribute part of this to Gluon-cv when I'm not busy.
-- Comes from @PistonY @haoxintong
A new loss function for representation learning. Circle Loss: A Unified Perspective of Pair Similarity Optimization
Just remind me to write.
And I may fix FP16
training bugs if anyone could success training with it, or I'll drop this. I'm not sure mxnet support mixed precision training.
What's the performance on MobileFaceNet_re?
NormDense中有些LOSS会对features和weights做L2归一化后再用全连接来分类?
class NormDense(HybridBlock):
# noinspection PyMethodOverriding
def hybrid_forward(self, F, x, weight, *args, **kwargs):
if self._weight_norm:
weight = F.L2Normalization(weight, mode='instance')
if self._feature_norm:
x = F.L2Normalization(x, mode='instance', name='fc1n')
return F.FullyConnected(data=x, weight=weight, no_bias=True,
num_hidden=self._classes, name='fc7')
Help me. I want to run arcface.
In the gluon docs,
warmup_lr, warmup_epochs, and warmup_mode
don't seem to be commented.
So when I commented out line 93, I also ran into the following problem:
有预训练的模型下载?
在center_loss中为了可视化:
增加一个(256,2)的全连接层来学习出坐标x,y,用它来和中心点计算center_loss
增加的这个全连接层形状输出是(batch,2),后面接分类的全连接层后输出是(batch,10)
就是把256通道变成2个通道,再由2个通道变成10个通道(10分类,10个数字),
网络结构通道都是图像减小通道数增加的过程,现在为了可视化最后2层变成了
通道急剧减少然后再增加,这个过程会不会影响最后一层信息的流动啊?
难道这样不影响分类??
你好,我使用训练好的模型移植到ncnn中,在手机端(小米8 高通845处理器)测试,一张人脸图像112*112仅抽取特征要50ms左右,使用insightface提供的训练好的模型来测试,基本也是一样的时间。但是mobilefacenet的论文中给出的测试时间是25ms之内,请问你们在手机端测试过吗?为什么会有这么大的差距呢?谢谢
The reason why float 16 yields nan is because the number of classes exceeds the range of float16. Thus, some of the labels are inf and cause the network to diverge. Some of the predictions are also inf. Any solutions?
我们想测试一下不同分辨率的识别精度问题,如果要不同的分辨率,是不是只用修改transform函数增加一个resize,还有backbone对应修改下采样就可以了。其它有和分辨率有关的要求吗?
insightFace训练过程是分两步,先做softmax的预训练再做arcLoss训练
suppose in_c == out_c
for basic_block:
total_params = 1 * 1 * in_c * 4 * out_c + 3 * 3 * 4 * out_c * 4 * out_c + 1 * 1 * 4 * out_c * out_c = 152 * out_c * out_c
-IR block:
total_params = 3 * 3 * in_c * 4 * out_c + 3 * 3 * 4 * out_c * out_c = 72 * out_c * out_c
Python2和Python3都支持吗?
In resources/mnist-euclidean directory, several pictures show how feature distribution changes on different training sets.I'm a little confused about the result of ringloss.
with a higher learning rate of 0.1, ringloss leads to a better result on trainset; but with a lower learning rate of 0.01, it leads to a better result on valset. Why would ringloss lead to such a strange result?
请问 有写关于这些loss的单元测试吗,这样的话修改和学习都会方便很多呢
你好,我先问下目前gluon-face在lfw中的精度达到多少呢
Hi,
MXNet nightly builds have been moved from PyPI to S3 (pypi/support#243). If this project requires the nightly builds for CI validation, please make sure that your CI pipeline now takes the nightly builds from https://dist.mxnet.io/python. Furthermore, as MXNet 1.7 and 2.0 are currently in progress simultaneously, we are releasing nightly builds for both 1.x and 2.x. Take mxnet-cu102
for example:
If you need the nightly builds for 1.x:
pip install --pre "mxnet-cu102<2" -f https://dist.mxnet.io/python
If you need the nightly builds for 2.x:
pip install --pre "mxnet-cu102>=2" -f https://dist.mxnet.io/python
Feel free to close this issue if the necessary changes have been made, or If the project doesn't rely on MXNet nightly builds. Thanks.
代码中处理FC7层权重的学习率和权重衰减与insightFace不一样
insightFace中是单独对FC7层权重做了学习率和权重衰减的:
_weight = mx.symbol.Variable("fc7_weight", shape=(args.num_classes, args.emb_size), lr_mult=args.fc7_lr_mult, wd_mult=args.fc7_wd_mult)
但是gluon-face是做的全局学习率和权重衰减
thx for sharing the project,im new to fr,is there any different between training and not training?bcs i compare features gen by two different people,but the score is 0.98,that confused me a lot! what should i do?
I'm going to write a test module and create CI.
Any suggestions could write below.
我在训练过程中,也是按照你脚本中设定的loss warm up =35000来设置,先使用softmax做warm up,然后使用arcloss,到34500个迭代后就挂掉,出现下面错误:
Traceback (most recent call last): File "train_script.py", line 269, in <module> train() File "train_script.py", line 201, in train losses = [Loss(yhat, y.astype(dtype, copy=False)) for yhat, y in zip(outputs, labels)] File "train_script.py", line 201, in <listcomp> losses = [Loss(yhat, y.astype(dtype, copy=False)) for yhat, y in zip(outputs, labels)] File "/home/trainer/anaconda3/envs/mxnet_py36/lib/python3.6/site-packages/mxnet/gluon/block.py", line 548, in __call__ out = self.forward(*args) File "/home/trainer/anaconda3/envs/mxnet_py36/lib/python3.6/site-packages/mxnet/gluon/block.py", line 925, in forward return self.hybrid_forward(ndarray, x, *args, **params) File "/home/trainer/anaconda3/envs/mxnet_py36/lib/python3.6/site-packages/gluonfr-1.0.1-py3.6.egg/gluonfr/loss.py", line 210, in hybrid_forward File "/home/trainer/anaconda3/envs/mxnet_py36/lib/python3.6/site-packages/mxnet/gluon/loss.py", line 347, in hybrid_forward loss = -F.pick(pred, label, axis=self._axis, keepdims=True) File "<string>", line 89, in pick File "/home/trainer/anaconda3/envs/mxnet_py36/lib/python3.6/site-packages/mxnet/_ctypes/ndarray.py", line 92, in _imperative_invoke ctypes.byref(out_stypes))) File "/home/trainer/anaconda3/envs/mxnet_py36/lib/python3.6/site-packages/mxnet/base.py", line 253, in check_call raise MXNetError(py_str(_LIB.MXGetLastError())) mxnet.base.MXNetError: Shape inconsistent, Provided = [256,1], inferred shape=[256,256]
你好,我制作了自己的数据集为rec格式,但是训练的时候,有下面错误信息:
mxnet.base.MXNetError: Shape inconsistent, Provided = [440,2], inferred shape=[440,1],
可以指导一下吗?没发现哪里出错了
你好,请问你们使用float16训练了吗?精度和速度如何呢?使用float16训练会经常出现NAN,你们的训练log可以提供一下吗?谢谢
Moved to https://gluon-face.readthedocs.io/zh/latest/papers/index.html
昨天使用代码来跑一下模型试试,结果发现一直卡在 train_script.py中的这一行batch = next(batch_generator),我用的是4个v100,显存占用是正常的,但是gpu利用率一直为零,应该是一直卡在数据加载这一块。
单步调试发现在函数中
def inf_train_gen(loader):
while True:
for batch in loader:
yield batch
执行完这一句for batch in loader:,就一直卡在这里了
环境如下:
ubuntu16.04
mxnet版本是1.5.0
代码只修改了如下2处:
(1)将~/.mxnet/datasets/face的所有路径替换为自己的数据路径
(2)mobilefacenet-arcface.sh内容修改如下:
python train_script.py --dataset emore --batch-size 1760 --ctx 0,1,2,3 --dtype float32 -j 24 --lr 0.35 --lr-mode cosine --lr-warmup-iters 5000 --wd 0.00004 --no-wd -s 64 -m 0.5 -t lfw,agedb_30 -n mobilefacenet --niters 86000 --loss arcface --loss-warmup-iters 35000 --hybrid --cat-interval 500
Hi,
Great work on the gluon-fr toolkit. Any reason why the model_zoo package is not exposed in the API ? I see it has been commented out.
Thanks
We got some awesome results in FaceFrecognition.
Please look at our model_zoo
Network | Loss | Train Dataset | Weight Norm | Feature Norm | Hyperparameter | LFW Best | Details |
---|---|---|---|---|---|---|---|
mobile-facenet | ringloss | emore | Yes | No | lamda=0.01, lr=0.01, emb_size=512, batch_size=96*4 | 0.988167+-0.006431 | Initialize of R is important, it's preferred to use a large value, like 20. |
mobile-facenet | arcloss | emore | Yes | Yes | lr=0.01, emb_size=512, s=32, m=0.5, batch_size=128*4 | 0.994667+-0.004137 | Finetune the model of ringloss with acc 0.988 |
se_resnet18L | arcloss | emore | Yes | Yes | lr=0.1, emb_size=512, s=64, m=0.5, batch_size=128*4 | 0.992167+-0.004947 | Finetune the model of L2Loss with acc 0.655070 |
se_resnet50L | arcloss | emore | Yes | Yes | lr=0.1, emb_size=512, s=64, m=0.5, batch_size=(32*4)*4 | 0.997000+-0.002867 | Finetune the model of L2Loss with acc 0.97 |
attention56-nobnprelu | arcloss | emore | Yes | Yes | lr=0.1, emb_size=256, s=64, m=0.5, batch_size=32*32 | 0.997000+-0.002867 | Finetune the model of L2Loss at iter 5000 |
InsightFace result with L-Resnet50-IR:
Flip | False | True |
---|---|---|
lfw: | 0.997167+-0.002693 | 0.998167+-0.002291 |
calfw: | 0.957833+-0.012089 | 0.977583+-0.020624 |
cplfw: | 0.886500+-0.017020 | 0.943944+-0.045293 |
cfp_fp: | 0.910571+-0.018683 | 0.932960+-0.036008 |
agedb_30: | 0.977667+-0.005925 | 0.936161+-0.040025 |
cfp_ff: | 0.998286+-0.001895 | 0.948447+-0.040840 |
Our SE_LResnet50:
Flip | False | True |
---|---|---|
lfw: | 0.997000+-0.002867 | 0.997167+-0.002587 |
calfw: | 0.957167+-0.010410 | 0.977083+-0.020488 |
cplfw: | 0.914333+-0.013421 | 0.955389+-0.033797 |
cfp_fp: | 0.968714+-0.008438 | 0.955800+-0.025998 |
agedb_30: | 0.963167+-0.008896 | 0.958387+-0.023843 |
cfp_ff: | 0.997429+-0.002195 | 0.964105+-0.025539 |
vgg2_fp: | 0.951400+-0.008002 | 0.962209+-0.022288 |
你好,训练完模型之后,原始代码在训练过程中只保存了params文件,并没有json文件。我在训练过程中使用train_net.export()函数来导出params和json文件,我看了一下params有45.7MB,json文件147kb。和你给的训练好的模型对比了一下,差别好大,你给的params才3.9MB,并且你给的json文件和我导出的json文件网络结构不一样,你是怎么做的呢?麻烦指导一下哈,谢谢
how get the output vector from a picture?can you provide the prediction codes? thank you
您好,感谢您的工作,最近训练模型时用到了arcloss,得到的loss值是nan,请问您有遇到这个问题吗?另外cosloss看代码实现没有看到跟余弦、正弦相关的 计算,这个感觉跟定义不太一样。希望能得到您的解答!
I'm now writing a eval script on megaface, IJB(B/C) and a black-box feature ext for IFRT test.
I should do this two years before actually. I'll make a pr when I finish this.
Line 331 in c06ed03
In original paper this line should divide by m(batch_size),
Or your lamda = lamda/barch_size
?
@haoxintong
Could you please release the current version to 1.0.2, the model_zoo package is still missing at this point that would be helpful to have it in the pip release.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.