FisherFace model training fails when missing training images (Bug #2253)


Added by Leo Dirac over 12 years ago. Updated almost 12 years ago.


Status:Cancelled Start date:2012-08-08
Priority:Low Due date:
Assignee:Philipp Wagner % Done:

0%

Category:python bindings
Target version:2.4.3 Estimated time:2.00 hours
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

The python demo in samples/python2/facereco_demo.py will fail with this error:

cv2.error: /home/vagrant/dl/opencv/modules/core/src/matrix.cpp:291: error: (-215) 0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols in function Mat

inside the call to model.train() if you change it to use FisherFace instead of EigenFace and point it to a directory of training data where many of the subdirectories are missing training images. (Why would you do this, I hear you ask... My pre-processing code rejected a bunch of images but left the directories in place.) So the labels are somewhat sparse. Removing the empty directories fixes the problem.

This is with unreleased code not sure if it's 2.4.3 branch or 2.5.0 branch -- git commit 8c3984c5ff290deb02beae6a31a5cfe89979e79e.


Associated revisions

Revision 82330a51
Added by Roman Donchenko about 11 years ago

Merge pull request #2253 from ilya-lavrenov:cuda

History

Updated by Philipp Wagner over 12 years ago

Yes, the read_images method is really simple. It was just intended to show how to read image data from your file system, because a lot of people have problems with the CSV file in the C++ demos. I'll (1) add a test to read_images, that'll check if the directory is empty and (2) a read_csv method, so you can also read a list with Comma Separated Values, that consists of <filename>;<label>.

  • Category set to python bindings
  • Estimated time set to 2.00
  • Assignee set to Philipp Wagner

Updated by Leo Dirac over 12 years ago

It's not about `read_images`. FisherFace always blows up like this unless if there isn't a training image with label value 0. The other models work with arbitrary integer labels, and Fisher works with any labels so long as 0 is present.

Updated by Leo Dirac over 12 years ago

Leo Dirac wrote:

It's not about `read_images`. FisherFace always blows up like this if there isn't a training image with label value 0. The other models work with arbitrary integer labels, and Fisher works with any labels so long as 0 is present.

Updated by Philipp Wagner over 12 years ago

If I do this in the demo on the labels (y) and a FisherFaces model it works as expected:

# Now read in the image data. This must be a valid path!
[X,y] = read_images(sys.argv[1])
if len(sys.argv) == 3:
   out_dir = sys.argv[2]

y = np.asarray(y) + 1

What input data are you using?

Updated by Philipp Wagner over 12 years ago

Could not reproduce, will be re-opened if more informations are given.

  • Status changed from Open to Cancelled

Updated by Konstantin Cherenkov almost 12 years ago

There is dependency between number of training images and number of unique labels.
If N -- number of training images and C -- number of unique labels,
It should be N == C (one training image per person) or N >= 2C-1.

Internally it is because PCA keeps N-C components

PCA pca(data, Mat(), CV_PCA_DATA_AS_ROW, (N-C));

And then LDA tries to take C-1 components

_eigenvalues = Mat(_eigenvalues, Range::all(), Range(0, _num_components));
_eigenvectors = Mat(_eigenvectors, Range::all(), Range(0, _num_components));

Also available in: Atom PDF