Skip to content

Embedding

Vladimir Mandic edited this page Nov 13, 2020 · 22 revisions

Face Feature Embedding and Simmilarity Compare


To use face simmilaity compare feature, you must first enable face.embedding module
and calculate embedding vectors for both first and second image you want to compare.

For example,

const myConfig = { face: { embedding: true }};
const human = new Human(myConfig);

const firstResult = await human.detect(firstImage);
const secondResult = await human.detect(secondImage);

const firstEmbedding = firstResult.face[0].embedding;
const secondEmbedding = secondResult.face[0].embedding;

const simmilarity = human.simmilarity(firstEmbedding, secondEmbedding);

console.log(`faces are ${100 * simmilarity}% simmilar`);

Embedding vectors are calulated values uniquely identifying a given face and presented as array of 192 float values

They can be stored as normal arrays and reused as needed

Simmilarity function calculates Eucilidean distance between all points in vector

Clone this wiki locally