ageitgey / ageitgey/face_recognition
Retrain KNN classifier model in face_recognition_knn.py
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 56.8k
- Forks
- 13.7k
- PR merge metrics
- No merged PRs in 30d
Description
- face_recognition version: latest version
- Python version: 3.6
- Operating System: Mac os High Sierra
Description
- I want to retrain the already classified knn model.
I am saving the knn pretained model on 10,000 images. Now, i am geting 10 more new images. I dont want to train the whole model again.
Can we train the new data seperately and add to the saved model ?
(or)
Is there any parameter for scikit knn algorithm that allows us to retrain the existing model ?
I am not sure if any of the 2 ways are correct. Any ideas or references to articles on how to implement any of this is much appreciated.
- I want to print the names of 2 nearest neighbours. what i did is:
faces_encodings = face_recognition.face_encodings(X_img, known_face_locations=X_faces_loc)
closest_distances = knn_clf.kneighbors(faces_encodings, n_neighbors=2)
is_recognized = [closest_distances[0][i] <= DIST_THRESH for i in range(len(X_faces_loc))]
print(is_recognized) # This prints [True True]
Now i dont understand how to parse is_recognized to print the recognized values. I want to print
names of all is_recognized
return [(pred) if rec for pred, rec in zip(knn_clf.predict(faces_encodings), is_recognized)]
Any guidance on printing the neighbouring names ?
This maybe the repost of ongoing talk at https://github.com/ageitgey/face_recognition/issues/319. But that thread became too long to address. So, just reframed it here.
Thank you,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with face_recognition_knn.py and trace how the saved KNN model is trained, queried with knn_clf.kneighbors, and used by predict. Review the referenced issue #319 and the scikit-learn KNN behavior. Done should clarify or support adding new training data without retraining everything and provide the names of the two nearest recognized neighbors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, scikit-learn
- Domain
- computer-vision, machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100