I'm planning on making a rather large database of faces/embeddings. I want to know whats the best way to sort my list of embeddings and I also want to know what's the best way to search my list for the most similar face. I'm using deepface for my facial recognition and identification.
Asked
Active
Viewed 144 times
-2
-
What do you call an *embedding* ? – Jan 11 '23 at 17:09
-
Best in what sense ? – Jan 11 '23 at 17:09
1 Answers
-1
Assume df['embeddings']
has a collection of all the embeddings you want to match against
face_embedding
is the one you're finding the nearest match to
Define the distance function
def find_distance(x):
if x is not None:
return distance.euclidean(x.detach().numpy(), face_embedding.detach().numpy())
else:
return None
Apply the distance function to the 'embeddings' column of the dataframe
df['distance'] = df['embeddings'].apply(find_distance)
Find the index of the closest match
closest_index = df['distance'].idxmin()
return closest_index

burnsi
- 6,194
- 13
- 17
- 27

nizar haider
- 1
- 1