Machine LearningComputer VisionModel Training

Face Recognition with ArcFace

Training a Vision Transformer Small (ViT-S) backbone to learn 512-dimensional face embeddings using the ArcFace training pipeline from InsightFace. The training workflow runs on Google Vertex AI Pipelines with GPU acceleration.

Overview

This project explores training a face recognition model from scratch using the ViT-S architecture provided by InsightFace's ArcFace toolkit.

The model learns discriminative facial representations through ArcFace-based classification training. Each input face is transformed into a 512-dimensional embedding, which can subsequently be used for face verification through cosine similarity.

The trained model is evaluated on six face verification benchmarks to investigate its generalization across different ages, poses, and facial appearances.

Embedding Size

512D

Evaluation Benchmarks

6

Backbone

ViT-S

Training Platform

Vertex AI

Model Architecture

The project uses the ViT-S backbone from InsightFace's arcface_torch implementation. The backbone processes aligned 112 × 112 face images and produces normalized feature representations for face recognition.

BackboneVision Transformer Small (ViT-S)
Input Size112 × 112
Patch Size9 × 9
Embedding Dimension512
Transformer Depth12 layers
Attention Heads8
NormalizationLayerNorm
Drop Path Rate0.1
Mask Ratio0.1

Dataset

The dataset contains training files and six standard face verification benchmarks. Only the training split is used during model optimization. Benchmark files are reserved for evaluation.

Face Recognition Dataset

Google Drive · Training and evaluation data

↗

Training Data

dataset/

├── train.rec

├── train.idx

├── train.lst

├── train.csv

└── train/

Evaluation Benchmarks

dataset/

├── agedb_30.bin

├── calfw.bin

├── cfp_ff.bin

├── cfp_fp.bin

├── cplfw.bin

└── lfw.bin

The evaluation datasets are kept separate from the training data to measure performance on unseen verification pairs.

Training Pipeline

Model training is orchestrated using Google Vertex AI Pipelines. The workflow separates dataset preparation from model training and configures dedicated compute resources for GPU-accelerated execution.

STEP 01

Download Dataset

Download the face recognition dataset and prepare the training and evaluation files.

STEP 02

Train Model

Load the training dataset, initialize the ViT-S backbone, and execute ArcFace training.

STEP 03

Evaluate Model

Evaluate the trained face embeddings against six standard face verification benchmarks.

Vertex AI Pipeline Configuration

The training component runs with the following compute configuration:

CPU

4 vCPUs

Memory

16 GiB

GPU

NVIDIA Tesla T4

GPU Count

1

arcface_training_pipeline.pyPython
@dsl.pipeline(name="arcface-training-pipeline")
def pipeline(train_config: str):
    # Download dataset
    data_task = download_data()

    # Train model
    train_task = train_model(
        dataset=data_task.outputs["dataset"],
        train_config=train_config,
    )

    # Configure compute resources
    train_task.set_cpu_limit("4")
    train_task.set_memory_limit("16Gi")
    train_task.set_accelerator_type("NVIDIA_TESLA_T4")
    train_task.set_accelerator_limit(1)

This pipeline makes training execution reproducible and allows dataset downloading and model training to run as separate pipeline components.

Training Toolkit

The project integrates InsightFace's arcface_torch implementation for model architecture, dataset loading, ArcFace training, and verification evaluation.

INSTALLATION

git clone --depth 1 --filter=blob:none --sparse \
    https://github.com/deepinsight/insightface.git

cd insightface

git sparse-checkout set recognition/arcface_torch
InsightFace GitHub Repository ↗

Evaluation Results

The trained ViT-S backbone is evaluated using six face verification benchmarks. Accuracy measures overall verification performance, while VAL at FAR = 1e-3 measures verification rate under a strict false acceptance constraint.

Best Accuracy · LFW

94.72%

CFP-FF Accuracy

94.16%

BenchmarkAccuracyVAL @ FAR 1e-3
AgeDB-3075.77%3.20%
CALFW82.88%19.90%
CFP-FP73.56%3.83%
CFP-FF94.16%57.49%
CPLFW65.17%0.47%
LFW94.72%75.43%

VAL values are reported as percentages. The original evaluation results also include standard deviations and observed FAR values.

Results Analysis

The model achieves relatively strong results on LFW and CFP-FF, but performance decreases on benchmarks involving more challenging age and pose variations.

LFW
94.72%

Strong general face verification baseline.

CFP-FF
94.16%

Good performance on frontal-to-frontal verification.

AgeDB-30
75.77%

Limited generalization across age variations.

CFP-FP
73.56%

Difficulty with frontal-to-profile verification.

CPLFW
65.17%

Significant challenges with cross-pose verification.

Limitations & Future Improvements

These results establish an initial baseline rather than a fully optimized face recognition model. Further experiments could investigate:

  • Training Configuration

    Experiment with training duration, learning rate, batch size, and optimizer settings.

  • ArcFace Loss

    Investigate margin, scale, and classification head configurations.

  • Data Preprocessing

    Verify face alignment, normalization, image quality, and color conventions.

  • Embedding Evaluation

    Review feature normalization, cosine similarity, and verification thresholds.

  • Benchmark Analysis

    Inspect false acceptance and false rejection cases across different variations.

  • Pretrained Initialization

    Compare training from scratch against pretrained backbone initialization.

Conclusion

This project establishes a baseline for training a Vision Transformer Small backbone using InsightFace's ArcFace pipeline, producing 512-dimensional face embeddings through a GPU-accelerated Google Vertex AI training workflow.

While the model achieves promising results on LFW and CFP-FF, its performance on age- and pose-related benchmarks indicates that further optimization is necessary to improve the robustness of learned facial representations.

PROJECT REPOSITORY

arcface-train

Explore the notebooks, training scripts, dataset preparation, Vertex AI pipeline, and evaluation implementation.

Explore on GitHub ↗