| embedding_distance | R Documentation |
Calculates the distance or similarity between two face embedding vectors.
embedding_distance(
emb1,
emb2,
metric = c("cosine", "euclidean", "euclidean_l2")
)
emb1 |
Numeric vector. First embedding. |
emb2 |
Numeric vector. Second embedding. |
metric |
Character. Distance metric to use:
|
For ArcFace and other angular-margin trained models, cosine distance is recommended as it aligns with the training objective.
Cosine distance ranges from 0 (identical) to 2 (opposite). Typical thresholds for same-person verification:
ArcFace + cosine: ~0.68
Facenet512 + cosine: ~0.30
Numeric distance value. Lower values indicate more similar faces.
## Not run:
emb1 <- get_embedding("face1.jpg")$embedding
emb2 <- get_embedding("face2.jpg")$embedding
# Cosine distance (recommended)
embedding_distance(emb1, emb2, metric = "cosine")
# Euclidean distance
embedding_distance(emb1, emb2, metric = "euclidean")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.