nwesem/mtcnn_facenet_cpp_tensorRT

ValueError: Expected n_neighbors <= n_samples, but n_samples = 93, n_neighbors = 100

Closed this issue · 5 comments

@shubham-shahh can you look into this?

Traceback (most recent call last):
  File "test.py", line 324, in sgie_sink_pad_buffer_probe
    result = predict_using_classifier(faces_embeddings, labels, face_to_predict_embedding)
  File "/opt/nvidia/deepstream/deepstream-5.1/sources/deepstream_python_apps/apps/facenet-python/facenet_utils.py", line 51, in predict_using_classifier
    yhat_class = classifier.predict(samples)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sklearn/neighbors/_classification.py", line 197, in predict
    neigh_dist, neigh_ind = self.kneighbors(X)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sklearn/neighbors/_base.py", line 683, in kneighbors
    (n_samples_fit, n_neighbors)
ValueError: Expected n_neighbors <= n_samples,  but n_samples = 93, n_neighbors = 100
[INFO] Classifier Training Done...

Please provide more context, are you training? Inferencing? C++ versi or or python?

  • Inferencing via facent-python.
  • generated the embeddings.npz
  • In deepstream_facenet.py I added the sgie_probe code from this to classify the faces from known_embeddings. There is facenet_utils.py. Which is basically a classifier (KNN, SVM).

then I was running that.

@shubham-shahh

  • Inferencing via facent-python.
  • generated the embeddings.npz
  • In deepstream_facenet.py I added the sgie_probe code from this to classify the faces from known_embeddings. There is facenet_utils.py. Which is basically a classifier (KNN, SVM).

then I was running that.

@shubham-shahh

Hi, It has something to do with your KNN classification, I cannot be sure until I see your code.

@imSrbh I guess the reason comes from your dataset. The number sample in your dataset is too small (only 93 images) but the number of nearest neighbors to query is K = 100. I think you should add more images to the dataset (greater than 100) or reduce the K value (maybe 5, 10, or 20 in this case)

@thandongtb Yes, you are right. I was able to resolve it.