Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Train dataset for temp stage can not be filled. Branch training terminated." #8

Closed
romulogcerqueira opened this issue Apr 14, 2015 · 8 comments

Comments

@romulogcerqueira
Copy link

I am trying to train a haar-like features using this tutorial, but I always have my training ended because this error:

"Train dataset for temp stage can not be filled. Branch training terminated."

How can I fix this?

@mrnugget
Copy link
Owner

Hey!

That's a pretty common error. See all these questions on the OpenCV board. There is not much I know about this error and I can only guess a solution, since there are a lot of possible reasons for that error.

And without any information about your setup there is nothing I can do.

@romulogcerqueira
Copy link
Author

I have 55 positive images and 395 negative images (all images are 32x32).

I created my pos.dat and neg.dat files as:

$ find positive_images/ -name '.jpg' -exec echo {} 1 0 0 32 32 ; > pos.dat
$ find negative_images/ -name '
.jpg' > neg.dat

Create my vec file as:
$ opencv_createsamples -info pos.dat -w 24 -h 24 -vec flowers.vec -num 55

And my training:
$ opencv_traincascade -data data_5 -vec flowers.vec -bg neg.dat -numStages 5 -numPos 55 -numNeg 395 -w 24 -h 24

And I got the following output error:
PARAMETERS:
cascadeDirName: data_5
vecFileName: flowers.vec
bgFileName: neg.txt
numPos: 55
numNeg: 395
numStages: 5
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: HAAR
sampleWidth: 24
sampleHeight: 24
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed 55 : 55
NEG count : acceptanceRatio 395 : 1
Precalculation time: 2
+----+---------+---------+
| N | HR | FA |
+----+---------+---------+
| 1| 1| 1|
+----+---------+---------+
| 2| 1|0.0683544|
+----+---------+---------+
END>
Training until now has taken 0 days 0 hours 0 minutes 8 seconds.

===== TRAINING 1-stage =====
<BEGIN
POS count : consumed 55 : 55
NEG count : acceptanceRatio 395 : 0.123592
Precalculation time: 1
+----+---------+---------+
| N | HR | FA |
+----+---------+---------+
| 1| 1| 1|
+----+---------+---------+
| 2| 1| 0.265823|
+----+---------+---------+
END>
Training until now has taken 0 days 0 hours 0 minutes 16 seconds.

===== TRAINING 2-stage =====
<BEGIN
POS count : consumed 55 : 55
NEG count : acceptanceRatio 395 : 0.0283154
Required leaf false alarm rate achieved. Branch training terminated.

@mrnugget
Copy link
Owner

Sorry, I have no idea! Again, I can only guess.

And since this problem doesn't directly affect this project, I'm closing the issue for now.

@gloomyfish
Copy link

i have same problem, but when i put the bg.txt into build/bin directory, the error has gone, works fine now
i think it is a bug in opencv 3.1.0, since the -bg parameter did not support any path/dir, with the file name

@MahmoudAbdelRahman
Copy link

Hi,
I faced the same problem and was solved by modifying the bg.txt file . I've written the whole address to the bg images as follows :

E:\RProj\ALL_LABELS\trees\negative\img_0.jpg
E:\RProj\ALL_LABELS\trees\negative\img_1.jpg
E:\RProj\ALL_LABELS\trees\negative\img_2.jpg
E:\RProj\ALL_LABELS\trees\negative\img_3.jpg
E:\RProj\ALL_LABELS\trees\negative\img_4.jpg
E:\RProj\ALL_LABELS\trees\negative\img_5.jpg
E:\RProj\ALL_LABELS\trees\negative\img_6.jpg
E:\RProj\ALL_LABELS\trees\negative\img_7.jpg
E:\RProj\ALL_LABELS\trees\negative\img_8.jpg
E:\RProj\ALL_LABELS\trees\negative\img_9.jpg
E:\RProj\ALL_LABELS\trees\negative\img_10.jpg
E:\RProj\ALL_LABELS\trees\negative\img_11.jpg
E:\RProj\ALL_LABELS\trees\negative\img_12.jpg
E:\RProj\ALL_LABELS\trees\negative\img_13.jpg
E:\RProj\ALL_LABELS\trees\negative\img_14.jpg
.
.
.
.

@DamonDBT
Copy link

also have this problem and do not find a way to handle this.

@rbk1234567
Copy link

Hello,
I want to confirm that paths in the bg.txt file need to be absolute.
On linux I was forced to use paths as /home/..../image.jpg to don't get this error.
Adding path as -bg parameter didn't work.
Used OpenCV 3.4.10 build

@ignacio-escalera
Copy link

Hi,
I faced the same problem and was solved by modifying the bg.txt file . I've written the whole address to the bg images as follows :

E:\RProj\ALL_LABELS\trees\negative\img_0.jpg
E:\RProj\ALL_LABELS\trees\negative\img_1.jpg
E:\RProj\ALL_LABELS\trees\negative\img_2.jpg
E:\RProj\ALL_LABELS\trees\negative\img_3.jpg
E:\RProj\ALL_LABELS\trees\negative\img_4.jpg
E:\RProj\ALL_LABELS\trees\negative\img_5.jpg
E:\RProj\ALL_LABELS\trees\negative\img_6.jpg
E:\RProj\ALL_LABELS\trees\negative\img_7.jpg
E:\RProj\ALL_LABELS\trees\negative\img_8.jpg
E:\RProj\ALL_LABELS\trees\negative\img_9.jpg
E:\RProj\ALL_LABELS\trees\negative\img_10.jpg
E:\RProj\ALL_LABELS\trees\negative\img_11.jpg
E:\RProj\ALL_LABELS\trees\negative\img_12.jpg
E:\RProj\ALL_LABELS\trees\negative\img_13.jpg
E:\RProj\ALL_LABELS\trees\negative\img_14.jpg
.
.
.
.

I was looking through the same situation and thankfully this was the answer, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants