I am using ORL face Database for face recognition. There are 40 subjects each with 10 images each. The size of each image is 112 * 92 pixels. For feature extraction and dimensionality reduction, I used 2D- PCA. The feature matrix is now 112*8.

Following is the code after feature extraction --

% TrainFaces --- shape is 240 * 112 *8 (contains 240 images (8 images of 40 persons))

% ValFaces --- shape is 80 * 112 *8 (contains 80 images (2 images of 40 persons))

% TestFaces --- shape is 80 * 112 *8 (contains 80 images (2 images of 40 persons))

% train_target -- shape is 40 * 240 (1st bit is 1 if it is 1st image and all rest zero)

% val_target -- shape is 40 * 240

% test_target -- shape is 40 * 240

EigenFaces = [TrainFaces ; ValFaces ; TestFaces];

target = [train_target val_target test_target];

%%%%%%%%%% Now we can convert feature matrix into feature vector %%%%%%%%%%%%%

input = [];

for i = 1:size(EigenFaces,1)

  • input = [input reshape(EigenFaces(i,:,:),size(EigenFaces,2)*size(EigenFaces,3),1)]; 

end

%%%%%%%% Creating Network and Training Them %%%%%%%%%%%

setdemorandstream(491218382);

net = patternnet(25);

net.divideFcn = 'divideind';

[net.divideParam.trainInd, net.divideParam.valInd, net.divideParam.testInd] = divideind(400,1:240,241:320,321:400);

net.trainFcn = 'trainrp';

[net,tr] = train(net,input,target);

%%%%%%%%%%%%% Testing the network %%%%%%%%%%%%%%%

predict = 0; % Number of correctly identified images out of 80

for i =1:80

  • [tar_val tar_ind] = max(test_target);
  • [out_val out_ind] = max(net(reshape(TestFaces(i,:,:),size(TestFaces,2)*size(TestFaces,3),1)));
  • if tar_ind == out_ind
  •    predict = predict +1;
  • end

end

predict

The predict always shows zero. Kindly help me analyse the graphs, thanks in advance.

Edit : I have uploaded the EigenFaces and Target values in the link given below. Kindly have a look.

http://goo.gl/DjfTWY

Similar questions and discussions