Cascade Classifier Training – FAQ, Known Issues and Workarounds

After receiving almost the same questions about Cascade Trainer GUI application all over again from many different users, I realized that it will be much more useful for anyone with a similar question, and much more efficient for me to actually compile a list of frequently asked questions, all the known issues and error and warning messages and try to answer them all in one place. Here is the result.

Question: What does this error mean and how to get around it? “Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.”

Answer: This is probably the one that is asked the most and I have written a whole post about it. Click here for more.

Question: How to fix this error? “Insufficient memory (Failed to allocate X bytes) in cv::OutOfMemoryError”

Answer: First of all, make sure you have enough memory on your computer. Second, make sure you set buffer sizes according to your available memory. In the example picture below, I assume we have at least 2 GBs available and I assign 1 GB of RAM to each one of the buffer types. Note that available memory is not the total memory. In this example I should have 4 GBs of RAM or something similar to that to be able to safely assign this much memory to the buffers.

Question: I received this message and the training stopped, what should I do? “Required leaf false alarm rate achieved. Branch training terminated.”

Answer: You can play around with the following parameters, but essentially what this error means is that there’s no point in further training since the required accuracy and performance and related settings are already reached, so the training stopped.

To further explain for people interested in more details I’ll be sharing the piece of code from OpenCV which is responsible for this error message and I think it pretty much speaks for itself:

for( int i = startNumStages; i < numStages; i++ )
{
cout << endl << "===== TRAINING " << i << "-stage =====" << endl;
cout << "<BEGIN" << endl;

if ( !updateTrainingSet( requiredLeafFARate, tempLeafFARate ) )
{
    cout << "Train dataset for temp stage can not be filled. "
            "Branch training terminated." << endl;
    break;
}
if( tempLeafFARate <= requiredLeafFARate )
{
    cout << "Required leaf false alarm rate achieved. "
            "Branch training terminated." << endl;
    break;
}
if( (tempLeafFARate <= acceptanceRatioBreakValue) && (acceptanceRatioBreakValue >= 0) ){
    cout << "The required acceptanceRatio for the model has been reached to avoid overfitting of trainingdata. "
            "Branch training terminated." << endl;
    break;
}

...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.