How to add new images to yml dataset?
Hi to everyone! I save the trained model:
trainedmodel->save("C:\\fisherface.yml");
And load it from the file pass:
trainedmodel->load("C:\\fisherface.yml");
But is there any way to update the yml dataset with new images or add some new images for existing person? I mean if i close my programm and after start it again i want to train some new faces and add it to existing yml dataset. Now if i use save function it just clears the previous data and stores the current model to it..
Thank you.
You can load the old data set and store it in a
cv::Mat
. Then you can concatenate the new data withcv::hconcat
orcv::vconcat
and save it again. I'm not sure if this is valid for classification data (I don't think so), but for feature or training data it should work. So in the second case you have to train again.Thank you for reply! What is the best practice to make a selftraining programm that stores and updates the dataset when it detect the new face? Can you advice what kind of scenario better to use: 1) Use LBPH model with update function. But how to add new data to yml dataset with update function? 2) Use Eigen or Fisher with concat function. Is there any code samples that shows how to use this function to add data to yml dataset? 3) Use images in folder and csv file with labels and filepass to images. And any time the new face detected, save the frame in image folder, write additional string to csv and retrain the model.
Thank you for advices...
with lbph it works like load() -> update(with new data) -> save()
whith fisher you have to keep your original data set, -> append new data to that -> train() -> save()
forget the hconcat idea, or anything like manipulating/adding to the yml files. it's the wrong idea, and won't work ever.
berak, can you explain please a little bit more clear what do you mean by "keep original data set" and "append new data to that"?
unfortunately, idk. exactly, what you are doing there, but you have to keep the original images around, load them again into a images list, add the new images, add new labels to the labels list, and then re-run the training. then you can save the new model.
Ok! Thank you berak. Now its clear. You meant the 3d option i posted before
ah, yes. looking up there, i think, so.
It would be great if someone share a code sample or similar project github link. I want to make a face recognition programm that can update faces and labels dataset dynamically during runtime and save the new faces for future use.