Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

SVM Prediction

Hello, this is my first time posting here. I am currently working on age estimation and extracting features using Gabor Filters. I have decided to classify ages using a SVM, the training is successful and it does not take a long time since the feature vectors are only about 3000 in dimensions by a 1000 training samples.

The problem is that when I want to predict an image, the result returned is always 18 (I pass the feature vector of the testing image to the predict function of the SVM). But when I predict an age from the training set the result is always correct. I do not know why this is happening. Any help will be appreciated.

Thank you for your time!

SVM Prediction

Hello, this is my first time posting here. I am currently working on age estimation and extracting features using Gabor Filters. I have decided to classify ages using a SVM, the training is successful and it does not take a long time since the feature vectors are only about 3000 in dimensions by a 1000 training samples.

The problem is that when I want to predict an image, the result returned is always 18 (I pass the feature vector of the testing image to the predict function of the SVM). But when I predict an age from the training set the result is always correct. I do not know why this is happening. Any help will be appreciated.

  do {
    sprintf(fullImagePath,"%s\\%s", imageDirectory, c_file.name);
    string label = c_file.name;
    float labelSubstring = atof(label.substr(15,2).c_str());
    labels.push_back(labelSubstring);

    Mat input = imread(fullImagePath,0);
    featureVector = ExtractFeatures(input);
    allFeatureVectors.push_back(featureVector.clone());
} while( _findnext( hFile, &c_file ) == 0 );

SVM svm;
CvSVMParams params;

params.svm_type = CvSVM::C_SVC;
params.kernel_type = CvSVM::RBF;
params.gamma=0.000308;
params.C=1000;
svm.train(allFeatureVectors,labels,Mat(),Mat(),params);

Mat testingSVMBud = imread ("C:\\Users\\Gabriel\\Desktop\\ae2.JPG",0);
Mat fV = ExtractFeatures(testingSVMBud).clone();
float prediction = svm.predict(fV);

Thank you for your time!