millburnai / aisecurity

CSII AI facial recognition.
11 stars 15 forks source link

Implement adaptive thresholding #31

Closed novialriptide closed 2 years ago

novialriptide commented 2 years ago

Fix: https://github.com/millburnai/aisecurity/issues/19

ryspark commented 2 years ago

Hey Andrew, thanks for working on this PR. Couple of requests before finishing this mini-project up:

Code organization

  1. compute_threshold method in facenet.py seems to just compute the dot product similarity between two vectors. Instead of defining a new method within the FaceNet class, it's best to use the existing DistMetric (from util/distance.py). Dot product distance is already implemented there in DistMetric.distance, maybe you could make an auxiliary method similarity that just returns 1 - self.distance().

Performance

  1. find_threshold creates a copy of self.data. Is it possible to rewrite that method without doing so? Not a big deal since it seems to only be called at init.
  2. apply_thresholds - if possible, can it be written without the nested for loop (ie vectorized)? If not, no big deal.
  3. find_similar_embedding - this should definitely be rewritten to avoid looping over self.data on each call. Better way to do this would be to use the SVM/KNN classifier (self.classifier.predict) to get the most similar embedding.
novialriptide commented 2 years ago

I resolved Code Organization: 1 and Performance: 3, I'm now working on the low-priority ones.

This PR adds some new things other than adaptive thresholding:

novialriptide commented 2 years ago

It looks like tests are failing, but in files unrelated to this pull request. I would like to create another pull request fixing these tests. @orangese.