| get_embedding | R Documentation |
Extracts a deep learning embedding vector from a face image using a specified model. The embedding can be used to compute face similarity.
get_embedding(
img_path,
model = "ArcFace",
detector = "retinaface",
align = TRUE,
enforce_detection = TRUE,
expand_percentage = 0
)
img_path |
Path to the image file containing a face. |
model |
Character. The face recognition model to use.
Default is "ArcFace". See |
detector |
Character. Face detection backend.
Default is "retinaface". See |
align |
Logical. Whether to align the face before embedding. Default is TRUE (recommended). |
enforce_detection |
Logical. If TRUE, raises an error if no face is detected. If FALSE, attempts to use the entire image. Default is TRUE. |
expand_percentage |
Numeric. Percentage to expand the detected face region. Default is 0. |
The embedding dimension depends on the model:
ArcFace: 512 dimensions
Facenet512: 512 dimensions
Facenet: 128 dimensions
VGG-Face: 4096 dimensions
One example configuration used in the package is:
model = "ArcFace"
detector = "retinaface"
align = TRUE
These defaults do not establish superior accuracy for every population, image source or research question, or validate lineup fairness.
A named list containing:
embedding - Numeric vector of face embeddings
facial_area - List with x, y, w, h of detected face region
face_confidence - Detection confidence score
## Not run:
# Get embedding for a single face
emb <- get_embedding("path/to/face.jpg")
# Access the embedding vector
emb$embedding
# Use a different model
emb_facenet <- get_embedding("path/to/face.jpg", model = "Facenet512")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.