Skip to main content

Face Embeddings

Face embeddings are mathematical representations of faces that enable comparison and matching. This page explains how embeddings work in Visage.

What is a Face Embedding?

A face embedding is a fixed-length numerical vector that represents the unique features of a face. The key property is that similar faces produce similar embeddings.

Properties

  • Fixed Length: Always the same dimension (128, 512, or 2622 depending on model)
  • Normalized: L2-normalized to unit length
  • Invariant: Relatively consistent across lighting and minor pose changes
  • Comparable: Can be compared using cosine similarity or Euclidean distance

Available Models

Facenet (Default)

  • Dimensions: 128
  • Speed: Fast
  • Accuracy: Good
  • Use Case: General purpose, default choice

VGG-Face

  • Dimensions: 2622
  • Speed: Slower
  • Accuracy: Very good
  • Use Case: When accuracy is critical

ArcFace

  • Dimensions: 512
  • Speed: Medium
  • Accuracy: State-of-the-art
  • Use Case: Best accuracy/speed tradeoff

OpenFace

  • Dimensions: 128
  • Speed: Very fast
  • Accuracy: Moderate
  • Use Case: Resource-constrained environments

How Embeddings Work

1. Face Preprocessing

Detected face region is:

  1. Aligned based on eye positions
  2. Resized to model input size
  3. Normalized pixel values

2. Neural Network Forward Pass

The preprocessed face is passed through a deep neural network trained to:

  • Map faces to embedding space
  • Ensure similar faces cluster together
  • Maintain distance between different people

3. L2 Normalization

The raw output is normalized to unit length:

normalized_embedding = embedding / np.linalg.norm(embedding)

Similarity Calculation

Visage uses cosine similarity to compare embeddings:

similarity = np.dot(embedding1, embedding2)

Since embeddings are L2-normalized, this simplifies to the dot product.

Range: 0.0 (completely different) to 1.0 (identical)

Configuration

Set the embedding model in your .env file:

FACE_MODEL=Facenet  # or VGG-Face, ArcFace, OpenFace

Model Comparison

ModelDimensionsSpeedAccuracyModel Size
Facenet128⭐⭐⭐⭐⭐⭐⭐⭐⭐~100MB
VGG-Face2622⭐⭐⭐⭐⭐⭐⭐~550MB
ArcFace512⭐⭐⭐⭐⭐⭐⭐⭐⭐~250MB
OpenFace128⭐⭐⭐⭐⭐⭐⭐⭐~30MB

Best Practices

  1. Consistent Model: Use the same model for registration and identification
  2. Multiple Samples: Register 3-5 embeddings per person
  3. Good Quality: Use well-lit, frontal face images
  4. Regular Updates: Re-register if appearance changes significantly

Next Steps