ageitgey / ageitgey/face_recognition

Grouping a collection of faces by person

Open
#433 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
56.8k
Forks
13.7k
PR merge metrics
No merged PRs in 30d

Description

I have a collection of face encodings, and I'd like to group them together (so, ideally, all the images of person 1 are in one group, all the images of person 2 are in a second group, etc). I'm working with the Python API.

My code currently works, to do this, but it's very slow (which will not surprise you when you see how it works). The algorithm is, basically:

for enc in big_list_of_encodings:
  for group in existing_groups:
    distances = fe.face_distance(group, enc)
    if more than half of distances < 0.6:
      # this matches most of this group: add it
      group.append(enc)
  if we matched no groups:
    # add a new group with just us in it
    existing_groups.append([enc])

This works very well indeed, which was a pleasant shock! However, it's pretty darn slow, not surprisingly; it walks over all the images again and again and again. What I don't know is: is there a better way to do this? I did look at the actual code, but I don't really understand about comparing large numpy vectors and so on, so I thought maybe there's a simpler way that I just don't know about to group together a big collection of vectors based on distance.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Python API and the face_distance calls described in the issue; review how the collection of encodings is currently compared. A useful resolution would identify a faster supported grouping approach and document its usage and performance, but the issue names no files, entry points, or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
computer-vision, machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.