Merging / Combining separately trained Fisherface models

asked 2015-08-13 02:00:40 -0600

muithi gravatar image


Is it possible to merge separately trained Fisherface models into one model? I am running into insufficient memory allocation and I was thinking maybe I could break down my training images into small data sets and train them separately (each data set of images trained will output one trained fisherface model ) because I have a large number of images I want to train and have one trained model in the end. I would like to know if this is feasible and if it is, how would I go about it? Is there a function for combining trained models into one in opencv or a way you would recommend I do it? I want to train around 12000 face images. My workstation only has 4Gb of RAM. I save the trained fisherface model in xml.


Joseph Mwema

edit retag flag offensive close merge delete



if you're talking about opencv's face recognition - no, it is not possible to merge trained pca/lda models. also you cannot update an existing fisher or eigen model.

both is only possible for the lbph model.

berak gravatar imageberak ( 2015-08-13 03:18:54 -0600 )edit

Thanks @berak for replying. How would I then go about training a fisherface model with 12000 face images? My application bombs out with insufficient memory allocation when I attempt to train with all the 12000 face images. I had already trained 12 fisherface models which I wanted to merge into one but unfortunately as you have indicated this does not seem to be a feasible option. What damage would it cause if I decided to merge the *.xml files of the separate models into one *.xml model?

muithi gravatar imagemuithi ( 2015-08-13 03:48:20 -0600 )edit
  • yes 12k images are a lot . even if you had enough memory, it would take until the sun melts..
  • no, there's no use merging the xml files. again, the eigenvectors and lda features from separately trained models are unrelated. the whole pca/lda idea only works, if it sees all the data at once.

what if you train 12 models, and later do 12 predictions per image (no fear, prediction is fast) then take the one with the shortest distance/confidence value ?

again, the lbph model is less limited wrt.

berak gravatar imageberak ( 2015-08-13 04:09:54 -0600 )edit

Thanks @berak for this insightful explanation. Infact I already trained 12 models. You have actually answered several other questions I had on my mind about using different other models for various recognition purposes on the same test image. I have never used more than one model in an application but that last pointer you made about prediction being fast is indeed a very good idea / suggestion. Thank you so much. This was very helpful. I appreciate.

I would rather use fisherface in preference to lbph model. Thank you.

muithi gravatar imagemuithi ( 2015-08-13 05:38:53 -0600 )edit

What resolution of input images are you using? I am guessing that you can go pretty low and still yield very good results. Or get a machine like me with 32GB of RAM :D

StevenPuttemans gravatar imageStevenPuttemans ( 2015-08-13 06:04:28 -0600 )edit

@StevenPuttemans I am now using 150 by 150 pixels. I was using 50 by 50 pixels initially and I was not getting good results. I decided to get loads of face images and had about 15000 of them but after doing face image processing on them (cropping, resizing and face alignment) I ended up with slightly over 12000 face images. I hope to get better results with 150 by 150 pixels.

You say I can get good results if I use face images with low resolution? I am actually steering away from that. Please explain how that would aid in getting good results? I like the approach suggested by @berak of using several predictions.

I wish I could lay my hands on a machine with 32Gb of RAM like you say ( that would have to be a 64 bit ) machine though, like a Proliant HP blade server or sth like that.

muithi gravatar imagemuithi ( 2015-08-13 07:50:33 -0600 )edit

Well i was just saying because face detection uses around 24x24 pxiels for training and the face recognizer in OpenCV using the AT&T dataset uses sizes of 92x112 pixels. Seeing that you can get up to 92.7% correct recognition on AT&T I am pretty convinced that using for example 100x100 pixels is more than enough information. I think it rather be due to the amount of classes that you have. In those 15000 faces, how many unique individuals do you have?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-08-14 03:39:55 -0600 )edit