I am trying to train a SVM with SIFT descriptors taken from images. And then i want to save the SVM in .xml
format so that i can load it again.
My structure: I have 10 classes with 100 samples from each class.
Question: If i use 10-50 samples for each class then the SVM gets saved and i can see a classifer.xml
file in my folder. But if i want to use more samples e.g. ~100 samples per class, then the SVM is not getting saved.
I thought that it might take some time for it to save but i have already waited for so long (and i have done it several times).
My code for SVM training is following:
void svm::svmTrain()
{
cv::Mat trainme; // it should contain the feature vectors
cv::Mat labels; // it will contain the class labels
createTrainingDateUsingBOW( trainme, labels);
//svm parameters
CvTermCriteria criteria = cvTermCriteria(CV_TERMCRIT_EPS, 1000, FLT_EPSILON);
CvSVMParams svm_params = CvSVMParams (CvSVM::C_SVC, CvSVM::POLY, 10.0 , 8.0 , 1.0 , 10.0 , 0.5 , 0.1 , NULL , criteria); //CvSVMParams --it is a struct
//( svm_type, kernel_type, degree , gamma , coef0 , Cvalue, nu , p , class_weights, term_crit)
cout<<"\n saving SVM \n";
cv::SVM svm;
svm.train(trainme, labels, cv::Mat(), cv::Mat(), svm_params);
svm.save("classifier.xml");
cout<<"\n SVM classifier is saved.";
}
PS: So if my samples are more 40-60 per class then, i reach upto saving SVM
from the above code but never reach to SVM classifier is saved.