Extracts a deep learning embedding vector from a face image using a specified model. The embedding can be used to compute face similarity.
Usage
get_embedding(
img_path,
model = "ArcFace",
detector = "retinaface",
align = TRUE,
enforce_detection = TRUE,
expand_percentage = 0
)Arguments
- img_path
Path to the image file containing a face.
- model
Character. The face recognition model to use. Default is "ArcFace" (recommended). See
available_models.- detector
Character. Face detection backend. Default is "retinaface" (most accurate). See
available_detectors.- 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.
Value
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
Details
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.