Closed yong2khoo-lm closed 3 years ago
Hi @kyygit, tnx! 🙂
Yes you need to retrain model every time you add new face, but there is a way to make this fast.
⚠️ Use code from
develop
branch for executing following commands, some thing are not merged intomaster
yet.
This will generate embeddings folder(slowest part):
python -m util.generate_embeddings --input-path path/to/images --output-path path/to/embeddings
Train your model (should be fast):
python -m training.train -e path/to/embeddings --grid-search
Now you have your trained model saved in model/face_recogniser.pkl
. Don't delete path/to/embeddings
folder, save it and use it for retraining.
You have new images of faces -> just add them to your folder with images (path/to/images
).
Generate new embeddings:
python -m util.generate_embeddings --input-path path/to/images --output-path path/to/new/embeddings --cache-folder path/to/embeddings
Notice the --cache-folder
here, this should point to old embeddings folder. If you didn't add too many new images, this should run fairly fast because it skips generating embeddings for old images.
Train your model:
python -m training.train -e path/to/new/embeddings --grid-search
There, you retrained your model. Every time you add new images, just repeat these steps.
Thanks for your quick reply. Shall test it out~
Hi, not sure if i miss anything...
I can only provide 2 arguments to util.generate_embeddings
:
input-folder
output-folder
If i provide "cache-folder
", it throws error as below:
error: unrecognized arguments: --cache-folder
Hi @kyygit, are you sure you are running this from develop
branch?
Is alright. I have my question answered. I was thinking, the reason of 're-train', is that the embedding of a person may vary based on the total persons trained. However, since you mention there is a cache, meaning, the embedding value of a person (of an identical photo) should be same. (correct me if i am wrong)
@kyygit you are right, embedding value of the same image (person) doesn't change.
First, appreciate your works :) As titled, would like to know if it is necessary to re-train those already trained? (when there is a new person added)