Git Product home page Git Product logo

Comments (8)

ageitgey avatar ageitgey commented on May 3, 2024 8

You could use multiple pictures of the same person a number of different ways. It just depends on your exact use case.

If you run face_recognition.face_encodings(picture_of_me)[0] on 30 pictures of the same person, you'll have 30 different encodings of the same person. Each encoding is an array of 128 numbers.

All 30 should be almost equal to each other (within 0.6 in euclidian distance across all 128 numbers), but of course that might not be the case. So you could handle that different ways:

  1. You could compare each unknown picture separately against all 30 known samples of the same person. This would work, but would be slow as you scale to more people. But it's easy to tell when someone is not a match for any of the known people.
  2. You could train any kind of classifier (like an SVM or whatever) like you said. In that case, you would still get a prediction that your unknown person matches one of your known people even if they aren't really a match. But you should get a low confidence score which you can use to determine that the match isn't good enough to consider a real match. So you can use that to know.

It really all depends on your use case. There's other cool stuff you can do like get the encodings for every image in a folder and use the Chinese Whispers algorithm to automatically cluster every face into groups where each group is one real person (i.e. discover all the individual people in a batch of images).

from face_recognition.

sluongng avatar sluongng commented on May 3, 2024 2

The facial encoding was generated based on a pre-trainned data set, which in turn was generated by deep learning algorithm. This ensure a certain accuracy and uniqueness for the generated facial encoding. It is expected that even if you use multiple images of a same person, the encodings variance should be insignificant toward classification usage. Ofc you could always setup a SVM to further enhance the process but that will come at the cost of performance and setup complexity for enhancement which expected to be minimal.

from face_recognition.

sluongng avatar sluongng commented on May 3, 2024 1

I dont even bother...

from sklearn.svm import SVC

encodings_array = []
names_array = []

with open('data.json') as json_data:
        nodes = json.load(json_data)
        for node in nodes:
            encodings_array.append(node['encoding'])
            names_array.append(node['name'])

clf = SVC()
clf.fit(encodings_array, names_array)

I just have all the name of people(string) into an array and fit them in without encoding.

later on I do

name = clf.predict([face_encoding])[0]

and wolalala

from face_recognition.

john-bonachon avatar john-bonachon commented on May 3, 2024

Wouldn't it be more accurate to train with multiple images of each person? Multiple images could help to build an "average" encoding of the person.

So if inside the "known images" folder the script finds a person folder, it would encode its face based on the average of all that person's single encodings. That makes sense?

I wonder if it could be a feature for the lib, or you just tell me if I'm in the wrong direction

from face_recognition.

john-bonachon avatar john-bonachon commented on May 3, 2024

If I'd setup a SVM, what label should I take as target label?
My columns are "filepath, filename, e1, e2, e3... e128", where e[1-128] are the encoding values

from face_recognition.

nadiagit avatar nadiagit commented on May 3, 2024

Hi, the label can be the name of the person in the image. So, if you have, for example, 30 images for each person, you will have 30 arrays (face_encodings) with the label person1; then another 30 arrays with label person2 and further on. After, http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelEncoder.html the labels can be encoded, in order to feed them to the SVM, http://scikit-learn.org/stable/auto_examples/svm/plot_iris.html#sphx-glr-auto-examples-svm-plot-iris-py. Therefore, fit (X, y, sample_weight=None) will receive as X the matrix with all the encodings(arrays) from all the pictures, and as y an array with all the labels.

from face_recognition.

john-bonachon avatar john-bonachon commented on May 3, 2024

This clarifies it a lot! Thanks
Just curious, SVC is a classifier, but what would you recommend to use to find similar faces? Just euclidian distance between encodings and then filtering using a threshold (~0.6).
Are there any other alternatives?

from face_recognition.

sluongng avatar sluongng commented on May 3, 2024

Great question @john-bonachon , I have just reaching this point myself.

In the original blog post of @ageitgey , he demonstrated using OpenFace demo classifier which used SVC.

You could check out this link for more classifiers available from sklearn. I strongly recommend going through each in detail to find suitable configuration for your use case 🔎

from face_recognition.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.