Giter VIP home page Giter VIP logo

face_verification_experiment's Introduction

Hi there 👋

face_verification_experiment's People

Contributors

alfredxiangwu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

face_verification_experiment's Issues

the LightenedCNN_B_lfw.mat result

Hello, I want to ask a question. How receives your program face_verification_experiment's result (LightenedCNN_B_lfw.mat)? Thanks!

pre-processing train data and val data

Hi:
thank you for your sharing code.
I know that pre-processing data for caffe train.
But i do not know that how to pre-processing train data and val data using your code for face verification.
can you give me some ideas?
thnaks

Data pre_processing: face alignment

Hi~, I would like to use the "face_db_align.m" to process the original CASIA-Webface database, but I have no 5 facial point files, would you like to share the landmarks files, thank you so much!

Share the training logs

I want to see your training logs of A and B to check if my training goes well or not.
And also, have you tried with RGB image instead of Gray Image?
Why didn't you specify the param about lr_mult and decay_mult in fc2 in B model?
Without specifying them, how does net work? And how did you set it in your training.
Thanks.

Open set protocols for identification testing

Hi, Wu.

In your paper "A lighten CNN for deep face representation", When you do open set identification testing, as for gallery set, you use 3143 images of 596 identities, why not follow standard rule: 596 subjects with a single face image per subject?
I tested your model B in this rule, got 59.63% (DIR@FAR=1%), I am not sure the result is correct or not.

As for VGG result in your paper, I think the verification result which you did not cite correctly in the VGG paper. You should cite accuracy not 100%-EER.
Also, do you test VGG model for close/open set for identification yourself?

Thank you.

EER && accuracy.measure不相等

hi,吴老师:
看您评估代码../face_verification_experiment/code/+evaluation/里有 +accuracy这一项,于是我就在evaluation.m加了句:
accuracy=evaluation.evaluate('accuracy',scores,label);
当载入您的LightenedCNN_A_lfw.mat时,EER和accuracy.measure都是97.77%(LightenedCNN_B_lfw.mat也都是98.13%)。
但如果通过载入模型LightenedCNN_A.caffemodel所提取出的特征mat时,测试其EER:96.87%,accuracy.measure:97.05%。

1.EER && accuracy.measure不相等
2.低于97.77%是什么原因呢?

多谢!

测试模型遇到的问题

吴老师,您好:
先感谢您分享的网络模型!
当测试模型时遇到两个问题:

  1. 按照网络A_deploy,提取fc1层的特征应该是512维(按这个正确率是93.8%),但看保存特征的mat里,特征维数是256维,想问一下,您提取的是那一层特征?
    2.在测试网络B_deploy时,出现 :
    ...insert_splits.cpp:35] Unknown blob input label to layer 1 的错误,想问一下这个怎么解决?

十分感谢!

where is meanfile?

hi Wu , i cannot find the meanfile of this LightenedCNN_A.caffemodel.

License of model

Hi, very nice of you to share the model of the face verification network! I couldn't find any license for the model, is it free to use both for commercial and non-commercial, or is it strictly non-commercial?

Invitation from a facial analysis community

Hi, Alfred,

It's a great work that you have achieved 97.77% on LFW using a single net! Not to say you have not used verification signal for traininig. Recently, we have built a open source community (Tencent QQ group) on facial analysis, including face detection, face alignment and face recognition, etc. Many teachers, researchers and students have moved in. I am hereby to invite you to join us for sharing your experience on your project, and also discuss with us on the face verifcation or relevant topics. It would be wonderful if you can join us!

The QQ number can be found on: https://github.com/jwyang/face-alignment

pool4 layer in ModelB

@AlfredXiangWu
You mentioned 5 pooling layers in B model in the paper.
However, there are only 4 pooling layers in the prototxt you posted.
Why different? which is more correct?
Thanks.

face verification threshold

Hi:
thnaks your for replying.
Extract the two face feature, after calculating the two faces of cosine distance. If the cosine distance is greater than a certain threshold, it is the same person, otherwise it is not the same person,
so how to determine the threshold?Artificial Settings?Or train?

thanks

Unknown bottom blob 'label' (layer 'accuracy', bottom index 1) about LightenedCNN_B_deploy

when i used the LightenedCNN_B_deploy.prototxt to initial the layer ,the program is wrong .
the excption message bellow:

layer {
name: "accuracy"
type: "Accuracy"
bottom: "prob"
bottom: "label"
top: "accuracy"
include {
phase: TEST
}
}
F0402 23:23:11.165431 70048 insert_splits.cpp:35] Unknown bottom blob 'label' (layer 'accuracy', bottom index 1)
*** Check failure stack trace: ***

try to extract layer ‘fc1’ feature using C++,but get an error

Pretrained model:
LightenedCNN_B.caffemodel
Net proto: LightenedCNN_B_ex.prototxt but change the input to (so that I can read the image_path in commend line):
layers {
name: "icub-camera"
type: MEMORY_DATA
top: "data"
top: "label"
memory_data_param {
batch_size: 1
channels: 1
height: 144
width: 144
}
}

Report
Cannot copy param 0 weights from layer 'fc1'; shape mismatch. Source param shape is 1 1 512 8192 (4194304); target param shape is 512 10368 (5308416).

What is wrong?

minus mean before train and test

Hi,
Thanks for your model and the implement details in your paper!
I look into your proto and find out that you do not minus mean file as general approach.
Do you minus the mean during the data pre-processing or not?
Do I need to minus mean when I extract feature?

Fine-tuning the B model.

@AlfredXiangWu
I am trying to do fine-tuning your B model.
I imitated your alignment and training method. but it's the same as training from first without model.
Loss starts from 25.70 and accuracy starts from 0.
What's the reason?
Thanks.

feature extracted difference

Hi, @AlfredXiangWu , I've trained a model following your paper, it works and shows good performance on valid set of casia_webface.

However, the performance on verific task was bad. I tried to use your release model and extract features from the lfw set. They queit difference from your released .mat features, and the accuracy was about 63%.

I think my alignment work was finished well using my reimplement of "Deep convolutional network
cascade for facial point detection" and your code face_db_align.m. Are there some extra works should be done when extracting the features? Thanks.

The question of manual correction facial points

I want to use modelB to reimplement LFW verification. I used 'code_face' and 'code_point' to generate LFW facial points. I set fixed position and size bboxes for all no detected bbox pictures. And I selected the largest area bbox for multiple bboxes pictures. The LFW validation accuracy is 96.05%.
Then I checked all LFW picture facial points, and fix 96 pictures facial points by hand. Now the LFW validation accuracy is 96.45%. But still below your results.
I used LFW data that deep_funneling downloaded from official website, And I only fixed facial points obvious error(facial points on wrong person or significant dislocation). Then I used 'face_db_align.m' to align images. In the end, I used matcaffe to extraction features, calculation cosine similarity, and using SVM to classification.

My problem is that which incorrect step made low validation accuracy?

By the way, I used features in 'LightenedCNN_B_lfw.mat', then reduction dimension to 100 by PCA, and can get 98.30% accuracy. Why dimension reduction, but the correct rate improve?
Thanks.

your caffe compile error

hi,
when i compile your caffer, i got an error;

[100%] Built target test.testbin
Scanning dependencies of target runtest
Cuda number of devices: 1
Current device id: 0
Note: Randomizing tests' orders with a seed of 18076 .
[==========] Running 836 tests from 167 test cases.
[----------] Global test environment set-up.
[----------] 10 tests from DataLayerTest/3, where TypeParam = caffe::DoubleGPU
[ RUN ] DataLayerTest/3.TestReadLevelDB
[ OK ] DataLayerTest/3.TestReadLevelDB (1748 ms)
[ RUN ] DataLayerTest/3.TestReadCropTestLevelDB
[ OK ] DataLayerTest/3.TestReadCropTestLevelDB (323 ms)
[ RUN ] DataLayerTest/3.TestReadCropTrainLevelDB
[ OK ] DataLayerTest/3.TestReadCropTrainLevelDB (311 ms)
[ RUN ] DataLayerTest/3.TestReadCropTrainSequenceUnseededLevelDB
[ OK ] DataLayerTest/3.TestReadCropTrainSequenceUnseededLevelDB (411 ms)
[ RUN ] DataLayerTest/3.TestReadCropTrainSequenceSeededLevelDB
[ OK ] DataLayerTest/3.TestReadCropTrainSequenceSeededLevelDB (455 ms)
[ RUN ] DataLayerTest/3.TestReadLMDB
[ OK ] DataLayerTest/3.TestReadLMDB (67 ms)
[ RUN ] DataLayerTest/3.TestReadCropTrainLMDB
[ OK ] DataLayerTest/3.TestReadCropTrainLMDB (44 ms)
[ RUN ] DataLayerTest/3.TestReadCropTrainSequenceUnseededLMDB
[ OK ] DataLayerTest/3.TestReadCropTrainSequenceUnseededLMDB (51 ms)
[ RUN ] DataLayerTest/3.TestReadCropTrainSequenceSeededLMDB
[ OK ] DataLayerTest/3.TestReadCropTrainSequenceSeededLMDB (50 ms)
[ RUN ] DataLayerTest/3.TestReadCropTestLMDB
[ OK ] DataLayerTest/3.TestReadCropTestLMDB (50 ms)
[----------] 10 tests from DataLayerTest/3 (3510 ms total)

[----------] 2 tests from HingeLossLayerTest/3, where TypeParam = caffe::DoubleGPU
[ RUN ] HingeLossLayerTest/3.TestGradientL1
[ OK ] HingeLossLayerTest/3.TestGradientL1 (7 ms)
[ RUN ] HingeLossLayerTest/3.TestGradientL2
[ OK ] HingeLossLayerTest/3.TestGradientL2 (4 ms)
[----------] 2 tests from HingeLossLayerTest/3 (11 ms total)

[----------] 5 tests from BenchmarkTest/1, where TypeParam = caffe::DoubleCPU
[ RUN ] BenchmarkTest/1.TestTimerStop
[ OK ] BenchmarkTest/1.TestTimerStop (0 ms)
[ RUN ] BenchmarkTest/1.TestTimerStart
[ OK ] BenchmarkTest/1.TestTimerStart (0 ms)
[ RUN ] BenchmarkTest/1.TestTimerConstructor
[ OK ] BenchmarkTest/1.TestTimerConstructor (0 ms)
[ RUN ] BenchmarkTest/1.TestTimerSeconds
[ OK ] BenchmarkTest/1.TestTimerSeconds (300 ms)
[ RUN ] BenchmarkTest/1.TestTimerMilliSeconds
[ OK ] BenchmarkTest/1.TestTimerMilliSeconds (300 ms)
[----------] 5 tests from BenchmarkTest/1 (600 ms total)

[----------] 3 tests from ThresholdLayerTest/2, where TypeParam = caffe::FloatGPU
[ RUN ] ThresholdLayerTest/2.Test
F1009 13:28:41.059129 11432 threshold_layer.cu:26] Check failed: error == cudaSuccess (8 vs. 0) invalid device function
*** Check failure stack trace: ***
@ 0x2b5e7d906daa (unknown)
@ 0x2b5e7d906ce4 (unknown)
@ 0x2b5e7d9066e6 (unknown)
@ 0x2b5e7d909687 (unknown)
@ 0xad8909 caffe::ThresholdLayer<>::Forward_gpu()
@ 0x7b3acf caffe::Layer<>::Forward()
@ 0x861c79 caffe::ThresholdLayerTest_Test_Test<>::TestBody()
@ 0x9f84ad testing::internal::HandleSehExceptionsInMethodIfSupported<>()
@ 0x9f38f6 testing::internal::HandleExceptionsInMethodIfSupported<>()
@ 0x9e0ccb testing::Test::Run()
@ 0x9e1464 testing::TestInfo::Run()
@ 0x9e1a52 testing::TestCase::Run()
@ 0x9e68dc testing::internal::UnitTestImpl::RunAllTests()
@ 0x9f9842 testing::internal::HandleSehExceptionsInMethodIfSupported<>()
@ 0x9f4635 testing::internal::HandleExceptionsInMethodIfSupported<>()
@ 0x9e5670 testing::UnitTest::Run()
@ 0x9d97b6 main
@ 0x2b5e7fb78ec5 (unknown)
@ 0x7a7859 (unknown)
@ (nil) (unknown)
Aborted (core dumped)
make[3]: *** [src/caffe/test/CMakeFiles/runtest] Error 134
make[2]: *** [src/caffe/test/CMakeFiles/runtest.dir/all] Error 2
make[1]: *** [src/caffe/test/CMakeFiles/runtest.dir/rule] Error 2
make: *** [runtest] Error 2
li@li:~/code/caffe/face/caffe-hybrid_dev/build$

how i can fix it?
thanks

caffe compile

hi,
i can use official caffe train your cnn net?
thanks

features reduce and evaluation

HI:
Thanks you for your replying.
I read your paper and code. i have two questions:g
one: why do not you reduce the features ? for example , when we get the 256 D features, we can use PCA to reduce the features.

two: i do not understand that why you use the vlfeat. i know that you use the caffe_ftr.py to extract features and use the matlab to get the cosine score. i think that if the cosine score greater than a certain threshold, then a same face. why do not you use the joint Bayesian?

thanks

5pt NOT exists

Thanks for your model!
But i have some problems in using face_db_align.m to align myself's samples。
Is ffp_dir the face_five_point?
And after I use Yi Sun's work to extract landmark, the samples's results were saved in a binary file (result.bin).

As I use the first function :
function res = face_db_align(face_dir, ffp_dir, ec_mc_y, ec_y, img_size, save_dir),

The error message is followed:
D:\github\Five_point_detector\code_point\image.\2000002_1493.5pt NOT exists.
??? Undefined function or variable "resize_scale".
Error in ==> face_db_align at 50
fprintf(log_fid, '%s %f\n', ffp_fn, resize_scale);

How do I use the result.bin?
Which function do i choose is correct?

Thanks very much!

train and val's data set

Thanks for your sharing code !
how many of webface-images are separately devided into training-inages and val-images?
(I set the ratio of train and val to 9 : 1. Was it right?)
Thanks!

B model does not converge.

I am trying to train with lightened_B model in CASIA.
I followed the training methodology in paper, But it does not converge.
At beginning, accuracy is 0, and loss is 87.3365.
What's the problem?
I am using caffe-windows-master of happynear(Feng Wang).
Thanks.

matlab evaluate error

hi ,
i run the matlab evaluation.m code . i got the error:
未定义与 'single' 类型的输入参数相对应的函数 'vl_pr'。
is there no "vl_pr" function?
thanks

Identify people with glasses

Hi everyone.

I'm recently implementing face verification in video surveillance. I'm using CASIA as training data and the CNN network mentioned in the CASIA paper. Although the model get 96% on LFW, there are still problems in real life situations. Now I'm facing the glass block problem. The model is often confused by people with similar thick black framed glasses. It can't separate their identities apart. This has been bugging me for two weeks and I hasn't come up with a robust solution yet.

Any thoughts?

The question of face detection

First, thank you for your contribution.
I use the modelB to reproduce the LFW face verification experiment. In the preprocessing stage, I use code_face to generates bbox file. But there are 157 pictures no detected bbox, and 580 pictures have multiple bboxes. So, I set fixed position and size bboxes for all no detected bbox pictures. And I selected the largest area bbox for multiple bboxes pictures.
Ten-fold cross-validation results is 96%, lower than 98.13% of your result.
So I want to know how do you handle these two cases?

By the way, In the windows system, lfw_pairs.mat that provided by you does not match images sort by name. for example the first pair of pos_pair is 57 60, but they are not the same people. So, I use the pairs.txt download from LFW official website to generating pairs file. Do you encountered this problem?
Thanks.

feature extraction

hi
when i use your python code for feature extraction. which layer is the feature layer?
fc1 or fc2?
thanks

training parameters

Hi, I want to train LightenedCNN_A from scratch, using a subset of CASIA-Webface, including 167K images.
I want to apply learning parameters as close to as your setup.
What is the actual number of your training and validation images?
What is the training batch size, and validation batch size?
What is the total number of iterations?
What is the initial and final learning rate, and how does it change btw. (sigmoid weight decay, exponential weight decay, fixed, etc?) When and how does the learning rate decrease? (actual iteration number)
Can you give all the parameters for LightenedCNN_A and LightenedCNN_B seperately?
Thanks in advance.

feature dimension

Hi, why the features stored in the matlab matrix is 256 dimensions? but fc1-layer in the network's output number is 512. I cannot understand which layer's output treat as the terminal feature!

matlab的提取特征计算两个分数跟你的差距有点大

Hi Wu, 我用你Amodel 提取特征然后用: cosTheta = dot(u,v)/(norm(u)*norm(v)) 计算,分数好像有些问题,估计是特征提取错误了。

以下是我的matlab的代码,请教下是否正确?

function [feature] = VerificationDemo2( image_file_1 )
addpath('E:\face\caffee\caffee-windows\caffe-windows\matlab');
if ~exist('model_inited','var')||~model_inited
caffe.reset_all();
caffe.set_mode_cpu();

same_thresh = 0.4;

MatAlignment('init_model','E:\ThirdPartyLibrary\dlib-18.14\shape_predictor_68_face_landmarks.dat');
net_model = 'E:\face\caffee\caffee-windows\caffe-windows\matlab\face_verification_experiment\proto\LightenedCNN_A_deploy.prototxt';
net_weights = 'E:\face\caffee\caffee-windows\caffe-windows\matlab\face_verification_experiment\model\LightenedCNN_A.caffemodel';

net = caffe.Net(net_model,net_weights, 'test');
model_inited = true;
model_inited64 = false;
end;
image1 = rgb2gray(imread(image_file_1));

J = zeros(height,width,1,20,'single');

face1 = MatAlignment('alignment',image1);
face1 = imresize(face1,[width height]);

I = single(face1)/256;
J(:,:,1,1) = I;
%net.set_input_scale('data', 20)
feature_size = 256;
feature_test = [];
H={J};
fea = net.forward(H);
% 特征层对于A是eltwise6,对于B是eltwise_fc1
output_blob_index = net.name2blob_index('eltwise6');%feature blob
output_blob = net.blob_vec(output_blob_index);
output = output_blob.get_data();
feature =output(:,1);
end

尤其是这个地方,

J = zeros(height,width,1,20,'single');

如果我写成zeros(height,width,1,1,'single'); 就会报

input data/diff size does not match target blob shape, input data/diff size: [ 128 128 1 1 ] vs target
blob shape: [ 128 128 1 20 ]

您好,我尝试训练您的CNN遇到困惑

首先感谢大神共享网络参数,我严格按照您的步骤,首先用港大的两个工具生成了人脸特征点文件,然后用您的matlab程序对齐了人脸,对齐的结果是有接近6W张无法检测到人脸或无法对齐或有多张人脸,我全部按照中心裁剪成144*144,剩下的可以对齐但与您论文的样例稍有差距,感觉上左右都比论文上多出了5-8个像素,请问这个误差怎么来的呢。
其次,我是采用每个目录的第一张做验证,现在最高能在softmax上达到74.355的test识别率,远远达不到85%-92%的区间内,请问是我训练有问题还是我选验证集的方式和您有出入?
还有,我在最后两个全链接层的初始化方法用 type: "gaussian",fc1用0.005 fc2用0.01,识别率低是否和这个有关?
望大神在百忙之中不吝赐教!!!!感谢

How do you set the MEAN?

Thanks for sharing your project ! I just follow your steps of alignment and extract features using your model and caffe_ftr.py,but I can just get acc 94% on LFW. So I want to ask whether you set the mean of data. And if you do ,how do you make your test data mean file?

Learning Robust Deep Face Representation

Hi Alfred Xiang Wu:

I've read your paper "Learning Robust Deep Face Representation", where you proposed a CNN architecture with Max-Feature-Map (MFM) activation functions. I compared it with the prototxt you uploaded here and I'm a little confused about the differences.

How do you apply your MFM layer? A convolutional layer, followed by a pooling layer, a slicing layer and an eltwise layer (prototxt) is the same as two consecutive convolutional layers, a MFM layer and a pooling layer (paper)?

Thank you very much!

Using matlab extracted feature by off the shelf caffemodel, but validation set is only 73%.

First, thank you for your contribution。

I write matlab code to extracting features and L2 Classification for LFW dataset. But only get 73% verification correct rate. The caffemodel and deploy.prototxt are provided by you.

The matlab code is:

dr_lfw_features = [];
for i= 1:length(fileLines)
    im = imread( fileLines{i} );    
    im = rgb2gray(im);
    im = imresize(im, [128 128]);
    im = single(im);
    im = im /256.0;
    im = im';

    blob_index_drop = net.name2blob_index('dropout1');%feature blob
    blob_drop = net.blob_vec(blob_index_drop);  
    net.forward({im});
    fprintf('iamge is %s, i = %d\n', fileLines{i}, i);
    blob_drop_data = blob_drop.get_data();
    blob_drop_data = reshape(blob_drop_data, 1, 256);
    dr_lfw_features = [dr_lfw_features; blob_drop_data];
end

load('dr_lfw_features.mat');
test_Intra = pairlist_lfw.IntraPersonPair;
test_Extra = pairlist_lfw.ExtraPersonPair;
test_pair = [test_Intra; test_Extra];

F1_index = test_pair(:,1);
F2_index = test_pair(:,2);

AllFeature1 = dr_lfw_features(F1_index, :);
AllFeature2 = dr_lfw_features(F2_index, :);

num = length(AllFeature1);
F1 = AllFeature1;
F2 = AllFeature2;
thresh2 = zeros(num,1);
for i = 1:num
    thresh2(i) = - sum((F1(i,:)/norm(F1(i,:)) - F2(i,:)/norm(F2(i,:))).^2);
end;
figure;
hist(thresh2(1:3000),500);
figure;
hist(thresh2(3001:end),500);

accuracies = zeros(1,1);
for i=1:10
    test_idx = [(i-1) * 300 + 1 : i*300, (i-1) * 300 + 3001 : i*300 + 3000];
    train_idx = 1:6000;
    train_idx(test_idx) = [];
    bestc=256;
    same_label = ones(6000,1);
    same_label(3001:6000) = 0;
    cmd = [' -t 0 -h 0'];
    model = svmtrain(same_label(train_idx),thresh2(train_idx),cmd);
    [class, accuracy, deci] = svmpredict(same_label(test_idx),thresh2(test_idx),model);
    accuracies(i) = accuracy(1);
end;
mean(accuracies)
cmd = [' -t 0 -h 0'];
model = svmtrain(same_label,thresh2,cmd);
[class, accuracy, deci] = svmpredict(same_label,thresh2,model);

By hist histogram, you can see the same data threshold and different data threshold obviously inseparable.
I think there are errors in this matlab, do you have any good suggestions?

Could not reproduce your LFW-closed set results

Hi, I want to reproduce your results mentioned in your paper arXiv:1511.02683 "A Lightened CNN for Deep Face Representation".
Although you claim that the fc1 layer dimension is 256 in your paper, it is actually 512 in your prototxt file. I used Dlib to detect and extract faces of LFW-closedset. Dlib in addition, rotates faces to align wrt the centers of eye locations horizontally. Then I resized the faces to 128x128 pixels. Then I used your LightenedCNN_A caffemodel release to extract features from fc1 layer, which has 512 dimensionality, using matcaffe latest release. One thing to note is, you did not release the mean binaryproto file of your training set. Don't you apply mean normalization before testing?
I compared the probe features with gallery features using cosine similarity. I obtained very low Rank-1 accuracy (less than %10). What would be the reason of the difference with your results?

High Error rate in Classification

Hi Alfred,
I was testing your pretrained model on CASIA-Webface itself. While evaluating the images under CASIA-WebFace/0005282/ I get the following result:
016.jpg predicted class: 8315
009.jpg predicted class: 6904
036.jpg predicted class: 8344
019.jpg predicted class: 1798
024.jpg predicted class: 1798
017.jpg predicted class: 4576
011.jpg predicted class: 1798
029.jpg predicted class: 10047
033.jpg predicted class: 6232
012.jpg predicted class: 1452
034.jpg predicted class: 6904
026.jpg predicted class: 1452
031.jpg predicted class: 1798
027.jpg predicted class: 6904
021.jpg predicted class: 9743
001.jpg predicted class: 1452
018.jpg predicted class: 6904
002.jpg predicted class: 8616
038.jpg predicted class: 1798
007.jpg predicted class: 1452
032.jpg predicted class: 9400
040.jpg predicted class: 10427
010.jpg predicted class: 10427
025.jpg predicted class: 1452
006.jpg predicted class: 9137
014.jpg predicted class: 8153
037.jpg predicted class: 6759
013.jpg predicted class: 10427
023.jpg predicted class: 1798
028.jpg predicted class: 9400
030.jpg predicted class: 1798
039.jpg predicted class: 1798
015.jpg predicted class: 6998
005.jpg predicted class: 10427
003.jpg predicted class: 10427
008.jpg predicted class: 9248
020.jpg predicted class: 6904
022.jpg predicted class: 7846
004.jpg predicted class: 2791
035.jpg predicted class: 6904
041.jpg predicted class: 1798

The predictions look very random to me. Here is my code that produced this result:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from os import walk

caffe_root = '/home/ambar/caffe/'
import sys
sys.path.insert(0, '/home/ambar/caffe/python')
import caffe

MODEL_FILE = '/home/ambar/casia-network/face_verification_experiment/proto/DeepFace_set003.prototxt'
PRETRAINED = '/home/ambar/casia-network/face_verification_experiment/model/DeepFace_set003_net_iter.caffemodel'

caffe.set_mode_gpu()
net = caffe.Classifier(model_file=MODEL_FILE, pretrained_file=PRETRAINED, raw_scale=128, image_dims=(128,128), mean=None)
def outputClassification(img, mode=0):
    if (mode == 1): caffe.set_mode_gpu()
    im = caffe.io.load_image(img, False)
    prediction = net.predict([im])
    print 'predicted class:', prediction[0].argmax()
def getclasses(base):
    for (dirpath, dirnames, filenames) in walk(base):
        for i in filenames:
            print i,
            outputClassification(dirpath + i, 1)
getclasses('/home/ambar/casia/CASIA-WebFace/CASIA-WebFace/0000204/gray/') #images converted to gray without normalisation
getclasses('/home/ambar/casia/Normalized_Faces/webface/100/0000204/') #normalised images

I then ran the same on the normalised dataset Normalized_Faces/webface/100/0000204/, and get the same results: Everytime the class 1452 has a lot of predictions, whereas the other classes seem random. This happens with no matter which celebrity faces I choose.
Please tell me where I am going wrong.

Error of feature's extracking

Thanks for your shared model!

My problem is shape error,same with #9.
When I extract the feature (‘fc1’),your code is :

......
shp=blobs['fc1'].shape
......
features_shape = (len(image_list), shp[1], shp[2], shp[3]).
......

The layer's shape size is also 2,and info of shp is only :[20,512]. There is no info of shp[2],shp[3]

I try to change test code for 6000 pairs matching:


...
import sklearn.metrics.pairwise as pw
def read_imagelist(filelist):
       fid =open(filelist)
       lines=fid.readlines()
       test_num=len(lines)
       fid.close()

       X=np.empty((test_num,1,128,128))
       i=0
       for line in lines:
              word=line.split('\n')
              filename=word[0]
              im1=skimage.io.imread(filename,as_gray=False)
              image=skimage.transform.resize(im1,(128,128))*1#Normalization

              #print 'gray:'+filename
              X[i,:,:]=image[:,:]

              i=i+1
       return X

def read_labels(labelfile):
       fin=open(labelfile)
       lines=fin.readlines()
       labels=np.empty((len(lines),))
       k=0;
       for line in lines:
              labels[k]=int(line)
              k=k+1;
       fin.close()
       return labels

def draw_roc(fpr,tpr,title='cosine',save_name='roc_lfw'):
       plt.figure()
       plt.plot(fpr,tpr)
       plt.plot([0,1],[0,1],'k--')
       plt.xlim([0.0,1.0])
       plt.ylim([0.0,1.0])
       plt.xlabel('FP')
       plt.ylabel('TP')
       plt.title('....:'+title)
       plt.legend(loc="lower right")
       plt.show()
       plt.savefig(save_name+'.png')


def evaluate(itera=500000,metric='cosine'):
       filelist_left='../left_all.txt'
       filelist_right='../right_all.txt'
       filelist_label='../label.txt'

       caffe.set_mode_gpu()
       net=caffe.Classifier('../DeepFace_set003_match.prototxt','../DeepFace_set003_net_iter.caffemodel')
       print 'net input:',net.inputs
       print 'net output:',net.outputs


       #Left feature
       X=read_imagelist(filelist_left)
       test_num=np.shape(X)[0]
       #out=net.forward_all(data=np.asarray([trans.preprocess('data',X)]))
       out=net.forward_all(data=X)
       ftr1=np.float64(out['fc1'])
       ftr1=np.reshape(ftr1,(test_num,512))

       #Right feature
       Y=read_imagelist(filelist_right)
       out2=net.forward_all(data=Y)
       ftr2=np.float64(out['fc1'])
       ftr2=np.reshape(ftr2,(test_num,512))

       labels=read_labels(filelist_label)
       assert(len(labels)==test_num)

       # cosine distance
       mt=pw.pairwise_distances(ftr1,ftr2,metric='cosine')
       predicts=np.empty((test_num,))
       for i in range(test_num):
              predicts[i]=mt[i][i]
       for i in range(test_num):
              predicts[i]=(predicts[i]-np.min(predicts))/(np.max(predicts)-np.min(predicts))

       print 'accuracy is:',accuracy(predicts,labels,test_num)

       np.savetxt('predicts.txt',predicts)
       fpr,tpr,thresholds=sklearn.metrics.roc_curve(labels,predicts)
       draw_roc(fpr,tpr,title=metric,save_name='lfw'+str(itera))

def accuracy(distance,labels,num):
       accuracy=[]
       predict=np.empty((num,))
       threshold=0.2
       while threshold<=0.8:
              for i in range(num):
                     if distance[i]>=threshold:
                            predict[i]=1
                     else:
                            predict[i]=0
              predict_right=0.0
              for i in range(num):
                     if predict[i]==labels[i]:
                            predict_right=1.0+predict_right
              current_accuracy=(predict_right/num)
              accuracy.append(current_accuracy)
              threshold=threshold+0.001
       return np.max(accuracy) 

The accuracy is always 0.5,
and the predicts are abnormal ,for example:
...
1.727013593861347891e-15
1.727013593861347891e-15
2.072416312633617391e-15
3.108624468950426086e-15
3.108624468950426086e-15
1.727013593861347891e-15
...
And the ROC curve is not a curve,but a straight line...

I know something is wrong(the feature of extracking??) with the changed code.
Could you help me to check the test code?
Thank you very much!

Feature extraction - shape error

Hi!

Thank you for sharing your approaches.

When I use your python code for feature extraction, I get the error "ValueError: could not broadcast input array from shape (64,3,28,28) into shape (64,1,28,28)". I am a little confused about what should I change.

I'm using as inputs:

  • your pretrained model (DeepFace_set003_net_iter.caffemodel)
  • your network definition (DeepFace_set003.prototxt)
  • an image list of some LFW grayscale images' path and labels

Thank you!!

关于模型的两个问题

老师您好
首先我想请问下 文章中进行测试时是对于LFW的原始数据集进行的特征点定位还是说根据deep funneled的图片进行的特征点定位呢
其次 readme里面写的利用caffe_ftr.py进行特征提取 但是我们在运行文件的时候提示说 'Classifier' object has no attribute 'set_phase_test'

training data preparation

I'm sorry to distrub you again with a issue about the project. How to prepare the training sample? I mean how to transform the image binary data into leveldb data. Could you show some detailed description about the transformed method?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.