I have a "training set" of images. I have formed the 'Eigenspace'. Now i need to label the projections to train the SVM. The projections of "face 1" to the Eigenspace has to be labelled +1 and the projections of all the other faces to the Eigenspace has to be labelled -1.
I don't know how to do this.Any suggestions would be really helpful!
I formed the eigenspace using the following :
function [signals,V] = pca2(data)
[M,N] = size(data);
data = reshape(data, M*N,1); % subtract off the mean for each dimension
mn = mean(data,2);
data = bsxfun(@minus, data, mean(data,1));
% construct the matrix Y
Y = data'*data / (M*N-1);
[V D] = eigs(Y, 10); % reduce to 10 dimension
% project the original data
signals = data * V;
If you are trying to recognize more than one person, you have to create one separate data file for each person, and one sepparate SVM for each person. This is because SVM are focused on two-class separation.
This is an example using libsvm for Matlab (here is the full code), supposing you have the data in a file:
To test one face, you need to apply all the models and get the max output (when using
svmpredict
you have to use'-b 1'
to obtain the probability estimates.Additionally, in Matlab you don't need to use
svmread
orsvmwrite
, you can pass directly the data:It seems that you cannot train the SVM... This is an example on how you can train a Matlab SVM: