wy1iu / sphereface Goto Github PK
View Code? Open in Web Editor NEWImplementation for <SphereFace: Deep Hypersphere Embedding for Face Recognition> in CVPR'17.
License: MIT License
Implementation for <SphereFace: Deep Hypersphere Embedding for Face Recognition> in CVPR'17.
License: MIT License
In sphereface, margin_inner_product_layer.cpp, line 277-278
you get gradient with respect to w using the same formula regardless of m: caffe_cpu_gemm(CblasTrans, CblasNoTrans, N_, K_, M_, (Dtype)1., top_diff, bottom_data, (Dtype)1., this->blobs_[0]->mutable_cpu_diff()); but
whereas in LargeMargin_softmax_loss, largemargin_inner_product_layer.cpp, line 263-356 you get gradient with respect to w according to m.
Can you tell me why?
Thanks.
I have two question:
In weight initialization of released model you use sometimes xavier
, sometimes gaussion
. Any reason why? I have implemented this network in PyTorch and xavier
for all layer works well for all network configuration expect 64
model (model diverge). And I'm searching reason why it does not work, maybe because of not mixed initialization? I checked other init method and non of them is working.
I would like to learn baseline model using pure SoftMax. Did you add any layer between embedding (size 512) and classification layer (size num_class), like PReLu or Dropout? I have learned model (20) without adding anything, but it overfitt ( I split data to train/val set).
Hi, @wy1iu, sphereface is quite a great work and i have some questions about the formula derivation in margin_inner_product_layer. Such as in "margin_inner_product_layer.hpp" file, why set "sign_0 = sign(cos_theta)", "sign_1 = sign(abs(cos_theta) - 0.5)", "sign_2 = sign_0 * (1 + sign_1) - 2", "sign_3 = sign_0 * sign(2 * cos_theta_quadratic_ - 1)", "sign_4 = 2 * sign_0 + sign_3 - 3".
If i want get a pent type, what variables "sign_5" should i set.
完全按照步骤要求进行训练,唯一的区别是限于只有单个6G显存的980T,只能单GPU以128的batchsize进行训练。始终不能收敛,请问这是batchsize过小引起的收敛问题吗? 谢谢!
Hi guys,
I tested A-Softmax loss on CASIA dataset and it really does well, reaching a ~99% performance on lfw without careful tuning. But when I switch to use the MS-Celeb-1M datasets for training(roughly cleaned, 98.8% lfw with Lighten CNN), either the 28-layer net nor the 64-layer net seems not to converge. The 64-layer net is the same as mentioned in your paper.
Have you tried A-Softmax in such large dataset? I am still trying to tune my net but have no idea why it doesn't converge.
Thank you for sharing the code. I have trained a model using 28layer (as the center face) with A-softmax, which works well. However, I have struggled training with the 64layer structure you mentioned in the original paper for several days. Could you please kindly release one of you network architectures in the paper (either 20layer or 36layer or 64layer) so I can compare the difference between the prototxt I wrote from yours.
BTW, it seems there is no pooling layer in your architecture, right? Just using convolution layer of stride 2 instead of pooling?
Thanks in advance!
Hi,
I set the random_seed in solver.prototxt, use the same CNN architecture and the same training set for evaluating the repeatability.
In softmax loss or softmax with centre loss, I can get the same softmax loss and same center loss in every iteration during training, but it is not the case in a-softmax (sphereface). In a-softmax, the first iteration is same, but it becomes difference when I repeat to train the model from scratch.
Would you like to explain it?
first , i train my model using original softmax
then, i want to finetune it using a-softmax
i intend to initialize the a-softmax's fc6 layer param using the original softmax, but the log says that they don't have the same number of param blobs, I found that margin inner product layer has no bias param blob.
i tried xavier initialization , but when i freeze the layers before fc6 and only learn fc6, the loss cannot converge .Do i have to relax the lr of the layers before fc6?
Hey, I trained the model as you mentioned in the README using the same ide and face datebase. But the loss increased from 7 to 87 after 10k iterations. Could you tell me how to analyse and solve this problem.
Hi,
The verification results reported on megaface website - http://megaface.cs.washington.edu/results/facescrubresults.html#verification - are:
Set 1 | Set 2 | Set 3
90.045% | 89.355% | 90.045%
However in your paper (table 5) you report the verification @ 10e-6 to be 85.561% (single model) and 89.142% (3patch ensemble), both being different than the number on MegaFace website, so which one are the correct results?
Thank you!
First of all, thank you for providing the Sphereface training code for us.
I have retrained your model following your instruction. However, I only got 67.35% on Rank-1 Identification Accuracy on Megaface testing, while you got 72.73%. We used your code and trained from scratch.
Training with Softmax + CenterLoss rendered the correct result as reported in your paper, i.e. ~65%.
I believe this is the same protocol you used for Megaface Testing, right? If not, could you kindly point out the difference? Thank you very much!
hello,my tutor asks me to use caffemodel to make a video demo,can you tell me how to do ,
thanks
Hello,
I tried to run the latest caffe version with largemargin layer however I get an error in the largemargin_inner_product_layer.hpp where it says the the Layer does take 2 arguments and not one (Ftype and Btype). Could you please update the code in the largemargin layer.
Thank you very much,
Best
I test the 20 layers sphereface network on my own database,then test the features on tSNE that generate by sphereface.But the result on tSNE doesn't perform better than the lcnn model.However it perform better than lcnn models(I trained) on lfw database.The sphereface net I had used is trained on MSceleb database and test on lfw database gets 98.65% acc.why the result of sphereface on the tSNE doesn't perform better than lcnn? Do you have test it on tSNE?
Hello,
Your previous submit use MTCNNv2 as the preprocessing algorithm.
However, the latest submit change to MTCNNv1.
Is there any reason for this change?
Which version is used in your paper?
Thanks very much.
In CenterFace and your SphereFace, your net models are both based on ResNets. But I noticed that neither of you use any BatchNorm layers (which differ from original resnets). I tried to add BatchNorm layers back. but got bad results (loss only converged to about 3.5).
So I'm really curious why BatchNorm layers are not good here. Any idea to explain this?
why the weight_diff is treated seperately according to m (SINGLE, DOUBLE, etc) in LargeMargin_softmax_loss wheras in sphereface, it is treated the same?
Hi --
What are the results (eg LFW accuracy) that we should expect when running this code as described in the README? I don't have MATLAB so I'll need to run w/ a different face detection/alignment pipeline, so I want to see how much error is introduced by my variant.
Thanks
In Margin Inner Product, the gradient with respect to weight is very simple:
// Gradient with respect to weight
if (this->param_propagate_down_[0]) {
caffe_cpu_gemm<Dtype>(CblasTrans, CblasNoTrans, N_, K_, M_, (Dtype)1.,
top_diff, bottom_data, (Dtype)1., this->blobs_[0]->mutable_cpu_diff());
}
But in large margin softmax, the gradient calcuation is much more complex...
Can you please tell me how to simplify the gradient calcuation?
I failed to derive it ...
I really grateful that @wy1iu release the code. You and @ydwen are really pushing the Face-Verification forward.
I have some question regarding the paper and the code:
Hi --
This is a question better directed at the https://github.com/ydwen/caffe-face issues, but issues are disabled and that project was written by some of the same authors.
The LFW features are available for download on the caffe-face
projects page -- is there evaluation code available to reproduce the 99% accuracy reported in the paper? The paper mentions using PCA on the features, but I haven't been able to get that kind of accuracy using the pretrained vectors. Any ideas?
Thanks
First of all thank you for your open code. You have developed a 20-layer Sphereface framework, and Is it necessary to study the 64-layer? Which of the two is better?
Hi, when I trained the sphereface-27 with my dataset, I always run into a problem:loss=87.33, and my prototxt as shown below:
layer {
name: "fc6-"
type: "MarginInnerProduct"
bottom: "fc5"
bottom: "label"
top: "fc6"
top: "lambda"
param {
lr_mult: 1
decay_mult: 1
}
margin_inner_product_param {
num_output: 11954
type: QUADRUPLE
weight_filler {
type: "xavier"
}
base: 10
gamma: 2e-05
power: 1
iteration: 0
lambda_min: 5
}
}
I0922 23:43:59.428972 192876 solver.cpp:219] Iteration 7000 (0.325212 iter/s, 307.492s/100 iters), loss = 10.0837
I0922 23:43:59.429009 192876 solver.cpp:238] Train net output #0: accuracy = 0.574219
I0922 23:43:59.429015 192876 solver.cpp:238] Train net output #1: lambda = 8.77178
I0922 23:43:59.429021 192876 solver.cpp:238] Train net output #2: softmax_loss = 10.0837 (* 1 = 10.0837 loss)
I0922 23:43:59.429025 192876 sgd_solver.cpp:105] Iteration 7000, lr = 1e-05
I0922 23:45:04.017473 192883 data_layer.cpp:73] Restarting data prefetching from start.
I0922 23:49:06.527763 192876 solver.cpp:219] Iteration 7100 (0.325632 iter/s, 307.096s/100 iters), loss = 7.03009
I0922 23:49:06.527886 192876 solver.cpp:238] Train net output #0: accuracy = 0.6875
I0922 23:49:06.527894 192876 solver.cpp:238] Train net output #1: lambda = 8.75641
I0922 23:49:06.527901 192876 solver.cpp:238] Train net output #2: softmax_loss = 7.03009 (* 1 = 7.03009 loss)
I0922 23:49:06.527905 192876 sgd_solver.cpp:105] Iteration 7100, lr = 1e-05
I0922 23:54:13.578683 192876 solver.cpp:219] Iteration 7200 (0.325682 iter/s, 307.048s/100 iters), loss = 8.27169
I0922 23:54:13.578783 192876 solver.cpp:238] Train net output #0: accuracy = 0.65625
I0922 23:54:13.578791 192876 solver.cpp:238] Train net output #1: lambda = 8.74111
I0922 23:54:13.578797 192876 solver.cpp:238] Train net output #2: softmax_loss = 8.27169 (* 1 = 8.27169 loss)
I0922 23:54:13.578801 192876 sgd_solver.cpp:105] Iteration 7200, lr = 1e-05
I0922 23:59:20.621175 192876 solver.cpp:219] Iteration 7300 (0.325691 iter/s, 307.039s/100 iters), loss = 12.1695
I0922 23:59:20.621300 192876 solver.cpp:238] Train net output #0: accuracy = 0.617188
I0922 23:59:20.621309 192876 solver.cpp:238] Train net output #1: lambda = 8.72585
I0922 23:59:20.621316 192876 solver.cpp:238] Train net output #2: softmax_loss = 12.1695 (* 1 = 12.1695 loss)
I0922 23:59:20.621321 192876 sgd_solver.cpp:105] Iteration 7300, lr = 1e-05
I0923 00:04:27.686278 192876 solver.cpp:219] Iteration 7400 (0.325667 iter/s, 307.062s/100 iters), loss = 10.945
I0923 00:04:27.686388 192876 solver.cpp:238] Train net output #0: accuracy = 0.664062
I0923 00:04:27.686394 192876 solver.cpp:238] Train net output #1: lambda = 8.71065
I0923 00:04:27.686416 192876 solver.cpp:238] Train net output #2: softmax_loss = 10.945 (* 1 = 10.945 loss)
I0923 00:04:27.686421 192876 sgd_solver.cpp:105] Iteration 7400, lr = 1e-05
I0923 00:09:29.417439 192876 solver.cpp:448] Snapshotting to binary proto file /home/unique/data-face/face_model/WT_sphereface27-40_iter_7500.caffemodel
I0923 00:09:31.971767 192876 sgd_solver.cpp:273] Snapshotting solver state to binary proto file /home/unique/data-face/face_model/WT_sphereface27-40_iter_7500.solverstate
I0923 00:09:35.155453 192876 solver.cpp:219] Iteration 7500 (0.325239 iter/s, 307.466s/100 iters), loss = 10.7305
I0923 00:09:35.155522 192876 solver.cpp:238] Train net output #0: accuracy = 0.644531
I0923 00:09:35.155529 192876 solver.cpp:238] Train net output #1: lambda = 8.6955
I0923 00:09:35.155535 192876 solver.cpp:238] Train net output #2: softmax_loss = 10.7305 (* 1 = 10.7305 loss)
I0923 00:09:35.155540 192876 sgd_solver.cpp:105] Iteration 7500, lr = 1e-05
I0923 00:14:42.234946 192876 solver.cpp:219] Iteration 7600 (0.325652 iter/s, 307.076s/100 iters), loss = 12.6641
I0923 00:14:42.235061 192876 solver.cpp:238] Train net output #0: accuracy = 0.652344
I0923 00:14:42.235069 192876 solver.cpp:238] Train net output #1: lambda = 8.6804
I0923 00:14:42.235076 192876 solver.cpp:238] Train net output #2: softmax_loss = 12.6641 (* 1 = 12.6641 loss)
I0923 00:14:42.235080 192876 sgd_solver.cpp:105] Iteration 7600, lr = 1e-05
I0923 00:19:49.294009 192876 solver.cpp:219] Iteration 7700 (0.325674 iter/s, 307.056s/100 iters), loss = 13.261
I0923 00:19:49.294123 192876 solver.cpp:238] Train net output #0: accuracy = 0.617188
I0923 00:19:49.294131 192876 solver.cpp:238] Train net output #1: lambda = 8.66536
I0923 00:19:49.294138 192876 solver.cpp:238] Train net output #2: softmax_loss = 13.261 (* 1 = 13.261 loss)
I0923 00:19:49.294142 192876 sgd_solver.cpp:105] Iteration 7700, lr = 1e-05
I0923 00:24:56.366257 192876 solver.cpp:219] Iteration 7800 (0.32566 iter/s, 307.069s/100 iters), loss = 13.8046
I0923 00:24:56.366369 192876 solver.cpp:238] Train net output #0: accuracy = 0.628906
I0923 00:24:56.366377 192876 solver.cpp:238] Train net output #1: lambda = 8.65037
I0923 00:24:56.366386 192876 solver.cpp:238] Train net output #2: softmax_loss = 13.8046 (* 1 = 13.8046 loss)
I0923 00:24:56.366391 192876 sgd_solver.cpp:105] Iteration 7800, lr = 1e-05
I0923 00:30:03.426719 192876 solver.cpp:219] Iteration 7900 (0.325672 iter/s, 307.057s/100 iters), loss = 14.3722
I0923 00:30:03.426854 192876 solver.cpp:238] Train net output #0: accuracy = 0.640625
I0923 00:30:03.426863 192876 solver.cpp:238] Train net output #1: lambda = 8.63543
I0923 00:30:03.426870 192876 solver.cpp:238] Train net output #2: softmax_loss = 14.3722 (* 1 = 14.3722 loss)
I0923 00:30:03.426877 192876 sgd_solver.cpp:105] Iteration 7900, lr = 1e-05
I0923 00:35:05.096544 192876 solver.cpp:448] Snapshotting to binary proto file /home/unique/data-face/face_model/WT_sphereface27-40_iter_8000.caffemodel
I0923 00:35:07.648367 192876 sgd_solver.cpp:273] Snapshotting solver state to binary proto file /home/unique/data-face/face_model/WT_sphereface27-40_iter_8000.solverstate
I0923 00:35:10.833468 192876 solver.cpp:219] Iteration 8000 (0.325305 iter/s, 307.403s/100 iters), loss = 17.3922
I0923 00:35:10.833523 192876 solver.cpp:238] Train net output #0: accuracy = 0.648438
I0923 00:35:10.833528 192876 solver.cpp:238] Train net output #1: lambda = 8.62054
I0923 00:35:10.833534 192876 solver.cpp:238] Train net output #2: softmax_loss = 17.3922 (* 1 = 17.3922 loss)
I0923 00:35:10.833539 192876 sgd_solver.cpp:105] Iteration 8000, lr = 1e-05
I0923 00:40:17.756762 192876 solver.cpp:219] Iteration 8100 (0.325818 iter/s, 306.92s/100 iters), loss = 17.3765
I0923 00:40:17.756888 192876 solver.cpp:238] Train net output #0: accuracy = 0.644531
I0923 00:40:17.756896 192876 solver.cpp:238] Train net output #1: lambda = 8.6057
I0923 00:40:17.756903 192876 solver.cpp:238] Train net output #2: softmax_loss = 17.3765 (* 1 = 17.3765 loss)
I0923 00:40:17.756908 192876 sgd_solver.cpp:105] Iteration 8100, lr = 1e-05
I0923 00:45:24.701261 192876 solver.cpp:219] Iteration 8200 (0.325795 iter/s, 306.941s/100 iters), loss = 17.4908
I0923 00:45:24.701335 192876 solver.cpp:238] Train net output #0: accuracy = 0.625
I0923 00:45:24.701341 192876 solver.cpp:238] Train net output #1: lambda = 8.59092
I0923 00:45:24.701349 192876 solver.cpp:238] Train net output #2: softmax_loss = 17.4908 (* 1 = 17.4908 loss)
I0923 00:45:24.701354 192876 sgd_solver.cpp:105] Iteration 8200, lr = 1e-05
I0923 00:50:31.609172 192876 solver.cpp:219] Iteration 8300 (0.325834 iter/s, 306.905s/100 iters), loss = 21.0124
I0923 00:50:31.609232 192876 solver.cpp:238] Train net output #0: accuracy = 0.625
I0923 00:50:31.609238 192876 solver.cpp:238] Train net output #1: lambda = 8.57618
I0923 00:50:31.609246 192876 solver.cpp:238] Train net output #2: softmax_loss = 21.0124 (* 1 = 21.0124 loss)
I0923 00:50:31.609249 192876 sgd_solver.cpp:105] Iteration 8300, lr = 1e-05
I0923 00:55:38.455067 192876 solver.cpp:219] Iteration 8400 (0.3259 iter/s, 306.843s/100 iters), loss = 26.4586
I0923 00:55:38.455188 192876 solver.cpp:238] Train net output #0: accuracy = 0.546875
I0923 00:55:38.455196 192876 solver.cpp:238] Train net output #1: lambda = 8.5615
I0923 00:55:38.455205 192876 solver.cpp:238] Train net output #2: softmax_loss = 26.4586 (* 1 = 26.4586 loss)
I0923 00:55:38.455210 192876 sgd_solver.cpp:105] Iteration 8400, lr = 1e-05
I0923 01:00:39.942590 192876 solver.cpp:448] Snapshotting to binary proto file /home/unique/data-face/face_model/WT_sphereface27-40_iter_8500.caffemodel
I0923 01:00:42.497731 192876 sgd_solver.cpp:273] Snapshotting solver state to binary proto file /home/unique/data-face/face_model/WT_sphereface27-40_iter_8500.solverstate
I0923 01:00:45.680984 192876 solver.cpp:219] Iteration 8500 (0.325497 iter/s, 307.223s/100 iters), loss = 27.8068
I0923 01:00:45.681020 192876 solver.cpp:238] Train net output #0: accuracy = 0.578125
I0923 01:00:45.681025 192876 solver.cpp:238] Train net output #1: lambda = 8.54686
I0923 01:00:45.681032 192876 solver.cpp:238] Train net output #2: softmax_loss = 27.8068 (* 1 = 27.8068 loss)
I0923 01:00:45.681036 192876 sgd_solver.cpp:105] Iteration 8500, lr = 1e-05
I0923 01:05:52.483103 192876 solver.cpp:219] Iteration 8600 (0.325946 iter/s, 306.799s/100 iters), loss = 28.9902
I0923 01:05:52.483191 192876 solver.cpp:238] Train net output #0: accuracy = 0.574219
I0923 01:05:52.483199 192876 solver.cpp:238] Train net output #1: lambda = 8.53228
I0923 01:05:52.483207 192876 solver.cpp:238] Train net output #2: softmax_loss = 28.9902 (* 1 = 28.9902 loss)
I0923 01:05:52.483211 192876 sgd_solver.cpp:105] Iteration 8600, lr = 1e-05
I0923 01:10:59.224231 192876 solver.cpp:219] Iteration 8700 (0.326011 iter/s, 306.738s/100 iters), loss = 45.9285
I0923 01:10:59.224365 192876 solver.cpp:238] Train net output #0: accuracy = 0.429688
I0923 01:10:59.224373 192876 solver.cpp:238] Train net output #1: lambda = 8.51774
I0923 01:10:59.224380 192876 solver.cpp:238] Train net output #2: softmax_loss = 45.9285 (* 1 = 45.9285 loss)
I0923 01:10:59.224385 192876 sgd_solver.cpp:105] Iteration 8700, lr = 1e-05
I0923 01:16:05.965823 192876 solver.cpp:219] Iteration 8800 (0.326011 iter/s, 306.738s/100 iters), loss = 62.0409
I0923 01:16:05.965976 192876 solver.cpp:238] Train net output #0: accuracy = 0.289062
I0923 01:16:05.965996 192876 solver.cpp:238] Train net output #1: lambda = 8.50326
I0923 01:16:05.966014 192876 solver.cpp:238] Train net output #2: softmax_loss = 62.0409 (* 1 = 62.0409 loss)
I0923 01:16:05.966025 192876 sgd_solver.cpp:105] Iteration 8800, lr = 1e-05
I0923 01:21:12.843422 192876 solver.cpp:219] Iteration 8900 (0.325866 iter/s, 306.874s/100 iters), loss = 67.5738
I0923 01:21:12.843535 192876 solver.cpp:238] Train net output #0: accuracy = 0.222656
I0923 01:21:12.843542 192876 solver.cpp:238] Train net output #1: lambda = 8.48882
I0923 01:21:12.843550 192876 solver.cpp:238] Train net output #2: softmax_loss = 67.5738 (* 1 = 67.5738 loss)
I0923 01:21:12.843554 192876 sgd_solver.cpp:105] Iteration 8900, lr = 1e-05
I0923 01:26:14.555048 192876 solver.cpp:448] Snapshotting to binary proto file /home/unique/data-face/face_model/WT_sphereface27-40_iter_9000.caffemodel
I0923 01:26:17.105406 192876 sgd_solver.cpp:273] Snapshotting solver state to binary proto file /home/unique/data-face/face_model/WT_sphereface27-40_iter_9000.solverstate
I0923 01:26:20.287829 192876 solver.cpp:219] Iteration 9000 (0.325265 iter/s, 307.441s/100 iters), loss = 65.0543
I0923 01:26:20.287881 192876 solver.cpp:238] Train net output #0: accuracy = 0.238281
I0923 01:26:20.287886 192876 solver.cpp:238] Train net output #1: lambda = 8.47443
I0923 01:26:20.287894 192876 solver.cpp:238] Train net output #2: softmax_loss = 65.0543 (* 1 = 65.0543 loss)
I0923 01:26:20.287899 192876 sgd_solver.cpp:105] Iteration 9000, lr = 1e-05
I0923 01:31:27.157495 192876 solver.cpp:219] Iteration 9100 (0.325875 iter/s, 306.866s/100 iters), loss = 87.3365
I0923 01:31:27.157562 192876 solver.cpp:238] Train net output #0: accuracy = 0
I0923 01:31:27.157569 192876 solver.cpp:238] Train net output #1: lambda = 8.46009
I0923 01:31:27.157577 192876 solver.cpp:238] Train net output #2: softmax_loss = 87.3365 (* 1 = 87.3365 loss)
What should I do to solve the problem? Thanks!
It is said only one image is registered for each person (could be the face detected for the first time), so in this case can I ask whether it is an open set test demo? E.g. the similarity between the registered face and the test titled one is always larger than the pre-set threshold (recognized as the same person). It seems once the face is detected, the recognition result is always right. Looking forward to your reply.
Hi,
I have just evaluated your 20-layer CNN architecture caffemodel in Megaface.
The results are below:
Rank-1 Identification Accuracy with 1 Million Distractors, Set1 (FaceScrub )
77.6892% (75.766% is their 68 layers published in the official homepage of Megaface )
Rank-1 Identification Accuracy with 1 Million Distractors, Set1, (testing age-invariant recognition at scale, FGNet)
23.5023% (47.555% is their 68 layers published in the official homepage of Megaface )
Is it right? did any other guys evaluate it as well?
I check the code, I think it can not ensure the theta in [0,pi/m]. if the theta is not in the [0,pi/m], I think it will be some wrong.
lfw acc:99.42% is incredible good;
About training set CASIA-WebFace, did you use clean_list or all images from CASIA?
I use this cleaned version casia,
https://groups.google.com/forum/#!topic/cmu-openface/Xue_D4_mxDQ
best result is
Accuracy: 0.990+-0.004
Validation rate: 0.92067+-0.02112 @ FAR=0.00100
Loss always stays around 9.3, not down
I set the learning rate to 0.01 and 0.06, and loss didn't converge???
How does the training network need to be modified?????
How is the training parameter set?????
Hope to get your help!!thanks!!
@wdwen
Hi,
in the figures of your papers you can see that the 3-patch net outperforms the one patch net and you say that the 3-patch feature vector is formed by concatenating the feature vectors of each patch. However, you do not say in your paper how these patches are computed. Do you use a different alignment strategy and train a new net on each type of aligned images or do you introduce a small offset and extract the 3-patch features by just transforming the original image a bit and computing the features with the original net?
Furthermore I get better results when not concatenating the features of the mirrored image. Has anyone experimented on that (patch selection/(not) mirroring) ?
Is there any pretrained model using this sphereface concept? If so how do i get the face embeddings of a custom image using that pre trained model?
How to evaluate the sphereface on Megaface?
Can i directly save the normalized embeddings and run the code "run_experiment.py" in the megaface devkit?
thanks
hi,proffesor, my data is much less than webface, how can i adjust superparameter to make the loss converge?
Hi,I followed your instruction to train CASIA-WebFace dataset, but the training loss stays around 9.3 at the very beginning. Could you please give some possible advises to solve this problem? Here is part of my train log.
####train log
I0907 20:56:08.035786 10605 caffe.cpp:218] Using GPUs 0
I0907 20:56:08.148684 10605 caffe.cpp:223] GPU 0: Tesla P40
I0907 20:56:08.807466 10605 solver.cpp:44] Initializing solver from parameters:
base_lr: 0.01
display: 100
max_iter: 28000
lr_policy: "multistep"
gamma: 0.1
momentum: 0.9
weight_decay: 0.0005
snapshot: 1000
snapshot_prefix: "result/sphereface_model_maxpy_clean/ckpt0907_2"
solver_mode: GPU
device_id: 0
net: "code/sphereface_model_maxpy_clean.prototxt"
train_state {
level: 0
stage: ""
}
stepvalue: 16000
stepvalue: 24000
stepvalue: 28000
I0907 20:56:08.812855 10605 solver.cpp:87] Creating training net from net file: code/sphereface_model_maxpy_clean.prototxt
I0907 20:56:08.815649 10605 net.cpp:51] Initializing net from parameters:
name: "SpherefaceNet-20"
###skip the model part
I0907 20:56:11.030130 10605 solver.cpp:218] Iteration 0 (-1.9811e-31 iter/s, 0.203529s/100 iters), loss = 9.20592
I0907 20:56:11.030190 10605 solver.cpp:237] Train net output #0: lambda = 892.857
I0907 20:56:11.030210 10605 solver.cpp:237] Train net output #1: softmax_loss = 9.20592 (* 1 = 9.20592 loss)
I0907 20:56:11.030252 10605 sgd_solver.cpp:105] Iteration 0, lr = 0.01
I0907 20:56:11.079816 10605 blocking_queue.cpp:49] Waiting for data
I0907 20:57:30.478466 10605 solver.cpp:218] Iteration 100 (1.25873 iter/s, 79.4451s/100 iters), loss = 9.33074
I0907 20:57:30.478658 10605 solver.cpp:237] Train net output #0: lambda = 76.2195
I0907 20:57:30.478673 10605 solver.cpp:237] Train net output #1: softmax_loss = 9.33074 (* 1 = 9.33074 loss)
I0907 20:57:30.478684 10605 sgd_solver.cpp:105] Iteration 100, lr = 0.01
I0907 20:58:46.554661 10605 solver.cpp:218] Iteration 200 (1.31453 iter/s, 76.073s/100 iters), loss = 9.30099
I0907 20:58:46.554803 10605 solver.cpp:237] Train net output #0: lambda = 39.8089
I0907 20:58:46.554821 10605 solver.cpp:237] Train net output #1: softmax_loss = 9.30099 (* 1 = 9.30099 loss)
I0907 20:58:46.554834 10605 sgd_solver.cpp:105] Iteration 200, lr = 0.01
I0907 21:00:32.839994 10605 solver.cpp:218] Iteration 300 (0.940902 iter/s, 106.281s/100 iters), loss = 9.41046
I0907 21:00:32.840147 10605 solver.cpp:237] Train net output #0: lambda = 26.9397
I0907 21:00:32.840165 10605 solver.cpp:237] Train net output #1: softmax_loss = 9.41046 (* 1 = 9.41046 loss)
I0907 21:00:32.840178 10605 sgd_solver.cpp:105] Iteration 300, lr = 0.01
I0907 21:02:01.073664 10605 solver.cpp:218] Iteration 400 (1.1334 iter/s, 88.23s/100 iters), loss = 9.35314
I0907 21:02:01.073825 10605 solver.cpp:237] Train net output #0: lambda = 20.3583
I0907 21:02:01.073848 10605 solver.cpp:237] Train net output #1: softmax_loss = 9.35314 (* 1 = 9.35314 loss)
I0907 21:02:01.073860 10605 sgd_solver.cpp:105] Iteration 400, lr = 0.01
I0907 21:03:35.687438 10605 solver.cpp:218] Iteration 500 (1.05697 iter/s, 94.6099s/100 iters), loss = 9.42017
I0907 21:03:35.687583 10605 solver.cpp:237] Train net output #0: lambda = 16.3613
I0907 21:03:35.687602 10605 solver.cpp:237] Train net output #1: softmax_loss = 9.42017 (* 1 = 9.42017 loss)
I0907 21:03:35.687613 10605 sgd_solver.cpp:105] Iteration 500, lr = 0.01
I0907 21:05:06.772781 10605 solver.cpp:218] Iteration 600 (1.09792 iter/s, 91.0816s/100 iters), loss = 9.3796
I0907 21:05:06.772953 10605 solver.cpp:237] Train net output #0: lambda = 13.6761
I0907 21:05:06.772974 10605 solver.cpp:237] Train net output #1: softmax_loss = 9.3796 (* 1 = 9.3796 loss)
I0907 21:05:06.772987 10605 sgd_solver.cpp:105] Iteration 600, lr = 0.01
I0907 21:06:23.862064 10605 solver.cpp:218] Iteration 700 (1.29725 iter/s, 77.086s/100 iters), loss = 9.37048
I0907 21:06:23.862254 10605 solver.cpp:237] Train net output #0: lambda = 11.7481
I0907 21:06:23.862272 10605 solver.cpp:237] Train net output #1: softmax_loss = 9.37048 (* 1 = 9.37048 loss)
P.S I've read the issue #14 and issue #7 , but neither provides feasible solutions. Could you please provide your solver settings and the lambda related parameters(lambda min, base and
gamma) for trainning? Thx a lot.
在video demo 里 , 人脸框并不是正的,这是怎么实现的?MTCNN冰没有这个功能啊?
have you train your a-softmax on a much more dataset for example msceleb1m.
I trained a-softmax on a 10m dataset, abount 200k identities, the loss did not converge,
but softmax or center loss done well.
Hi authors, I have tried your network structure with sphere loss and it can give similar result which mentioned in your paper. However, when I switched to use common resnet-50 or resnet-101 I can just got LFW score at about 97.xx%. Did you ever tried any other network structures?
I thought that the problem was caused by small norm(fx) where fx is the 512-dim embedding. As the W is normalized to one in sphereface, fx*W will become very small if norm(fx) is small to affect the total loss value.
According to this I tried two approaches:
Neither of them can work.
Do you have any idea or give some hints?
Since I only have 2*1080Ti, using batch_size=256 will out of mermory.
I set batch_size=64, so how to set the stepvalue,
stepvalue: 16000*4
stepvalue: 24000*4
stepvalue: 28000*4
max_iter: 28000*4
other parameters are same as the solver providied by this repository .
is it ok?
And if I use Relu instead of PRelu, is it just affecting the coverage time. How about the precision?
Hi wy1iu,
Asoftmax is a great work.I have some questions about how to set gamma and power for lambda.
Using the settings in your prototxt
(
base: 1000
gamma: 0.12
power: 1
lambda_min: 5
)
lambda will drop very quickly to lambda_min, is it really possible to converge?
what is the best way to setting these for different networks and different size of training data?
Thanks.
As I seen in your prototxt file, you didn't use neither batchnorm layer nor dropout. Why?
Does such layers affect the network converging?
Thanks in advance.
Hi,@wy1iu,i used the 20 layers network trained on casita dataset and extract feature on lfw dataset by concate original face image and flip face image features and finally get 98.97% accuracy, is is normal? I write a 64 layers network according to your paper and finally get 98.88% accuracy, why the deeper network get a worse result?
Hi, actually, follow your instruction, after 28000 iterations, the loss decrease to 4.x. So, my question is one model can be used correct, what loss should be decreased to? Or, I should reset the max iterations, 10000 or 200000?
Thank you
hello,
there are some paper normalize the features before input Softmax layer, and I think it's make sense because
(1)it will make the feature space more dense which suit for hyperplane to do classification.
(2)all feature be normalized will give larger gradients to hard samples.
I also think these ideas don't conflict with sphereface which depend on angular margin.
Do i think it right? and have you did such experiment?
Are you able to explain a couple of bits about the implementation of the margin_inner_product_layer
?
What is lambda_
? It looks like it's a constant that decreases w/ the iterations, but doesn't seem to be mentioned in the paper. ** Edit: Looks like you mix x'w
and margin(x'w)
via (margin(x'w) + lambda_ * x'w) / (1 + lambda_)
where lambda_
decreases exponentially w/ iterations. Is that right? **
What is the type
parameter? (eg. SINGLE, DOUBLE, TRIPLE, QUADRUPLE
) I'm guessing this is how you set the value of m
from the paper? ** Edit: I gather these are ways of implementing the margin for m={1,2,3,4}
. Any particular reason why you implemented this way? Numerical stability? **
Thanks
Since the WebFace contains 10,575 subjects, why using 10572?
Is that because mtcnn could only detect and align 10572 persons?
I'm using a face detection model and alignment method trained by myself.
comment describes coeff_x as
1 / (-|x|) * (sign_3 * (24 * cos_theta_quartic - 8 * cos_theta_quadratic - 1) + sign_4) * x
where the operator before sign_4_data is add
while in your code
Dtype coeff_x = (Dtype)1. / (-x_norm_data[i]) * (sign_3_data[i * N_ + j] *
((Dtype)24. * cos_theta_quartic_data[i * N_ + j] -
(Dtype)8. * cos_theta_quadratic_data[i * N_ + j] - (Dtype)1.) -
sign_4_data[i * N_ + j]);
the operator before sign_4_data is minus
So which one is right? By the way, could you describe more details about how to deduce the derivative? I only get the right coeff_w while coeff_x is too difficult to deduce.
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.