Ask Your Question
0

Opencv_haartraining does not converge

asked 2014-01-21 04:47:14 -0600

updated 2014-01-21 06:12:08 -0600

I'm running OpenCV2.4.7 on Windows8.

I'm using opencv_traincascade to train a new cascade for faces. I ran the following command:

opencv_haartraining.exe -data -haarcascadeold -vec vector20.vec -bg infofile2.txt -nstages 40 -minhitrate 0.9999999 -maxfalsealarm 0.5 -npos 9000 -nneg 26946 -w 20 -h 20 -mem 1024

However, it seems to get stuck: image description

This happens every time I run it, I even tried to change the values to -minhitrate 0.8 -maxfalsealarm 0.7. The first time, it ran for 180 iterations producing the exact same values.

have about 13,000 positives, but I set the npos to be 9000 so I won't run out of positive examples.

I have to use the old function instead of traincascade as my colleague wrote his code using the old C interface.

Can someone please explain the cause of this problem and how to fix it?

Thanks,

Gil

edit retag flag offensive close merge delete

Comments

Thanks @StevenPuttemans, Can you please tell me how to change the parameters/number of images so it would not act this way?

GilLevi gravatar imageGilLevi ( 2014-01-21 06:44:30 -0600 )edit
1

Thanks again @StevenPuttemans. I somehow managed to train a cascade using the new opencv_traincascade. It terminated after three days. Does that makes sense?

GilLevi gravatar imageGilLevi ( 2014-01-21 09:26:27 -0600 )edit

Thanks @StevenPuttemans, by "my model", do you mean the parameters -w -h? it was set to -w 10 -h 10 and all the 24K negative images were larger than that.

GilLevi gravatar imageGilLevi ( 2014-01-21 09:52:53 -0600 )edit

OK, @StevenPuttemans would you like to write an answer for the question for other people with similar problems?

GilLevi gravatar imageGilLevi ( 2014-01-21 13:14:13 -0600 )edit

Will copy my comments to a solution. You are welcome!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-22 02:32:00 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2014-01-22 02:35:41 -0600

The following remarks lead to solving the problem for @GilLevi:

REMARK 1:

Isn't it more effective to translate the old C - interface? Or just the parts that communicate with your interface? As to your output, I have never seen a classifier doing this, reproducing the exact same information for several stages. However, are you aware that you ask your algorithm to find 24000 unique windows at each stage that can be classified as negatives and haven't been correctly classified before? I think this is a point which will, certainly in later stages, never been reached...

SUBSEQUENT QUESTION:

Can you please tell me how to change the parameters/number of images so it would not act this way?

REMARK 2:

Well for that you actually need to understand how the negatives get grabbed. Normally you have a supplied a list of negative images, with random sizes, but larger than the size of your model, which contain no objects. Next the algorithm performs a sliding window approach, making sure that each window is tested to be unique? This means that if two following windows are equal, the second one isn't used for training. At each stage, all negatives used and correctly classified get discarded, so new ones need to be found. Imagine doing this with 24.000 windows, will take a huge amount of time to find those unique negatives. Why not start with like npos 5000 nneg 5000 and look at your performance there?

SUBSEQUENT QUESTION:

I somehow managed to train a cascade using the new opencv_traincascade. It terminated after three days. Does that makes sense? by "my model", do you mean the parameters -w -h? it was set to -w 10 -h 10 and all the 24K negative images were larger than that.

REMARK 3:

It is possible if your 24000 negative images are actually larger than your model. It depends on what the last output was. Probably a stage reached your desired hit ratio versus a low false acceptance rate.

Yea I do mean that. Aha with such a small model, finding that much negatives would indeed be possible. So the training will be correct :)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-01-21 04:47:14 -0600

Seen: 582 times

Last updated: Jan 22 '14