Run this model with HF Jobs

Run headless-start/parameter-efficient-dfer on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/headless-start/parameter-efficient-dfer. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/headless-start/parameter-efficient-dfer on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Parameter-Efficient Adaptation of Facial Expression Recognition Models for Driver Monitoring

Weights and evaluation records for the MSc thesis of Ayush Tiwari (BTU Cottbus-Senftenberg, 2026), comparing full fine-tuning, a linear probe, AdaptFormer and LoRA.

An ImageNet-pretrained ViT-B/16 is fine-tuned on six-class FER+ (Stage 1), then adapted to near-infrared KMU-FED face crops with a new classifier (Stage 2). The standalone loader below includes the model definitions and preprocessing.

Code: github.com/headless-start/parameter-efficient-dfer

Results

KMU-FED: 1,106 frames from 12 drivers, ten frame-block folds, 110 held-out frames per fold. Accuracy is the ten-fold mean ± sample standard deviation; weighted F1 pools all 1,100 held-out frames.

Strategy Selected setting Trainable parameters Accuracy (%) Pooled weighted F1 (%) Errors / 1,100
Full fine-tuning lr 3e-5 85,803,270 97.55 ± 4.11 97.54 27
Linear probe lr 3e-3 4,614 93.27 ± 6.83 93.22 74
AdaptFormer lr 1e-3, width 64 1,194,246 98.45 ± 2.43 98.45 17
LoRA lr 1e-3, rank 4 152,070 99.00 ± 2.59 99.00 11

FER+ six-class official test: 93.21 % accuracy and 93.13 % weighted F1 over 2,047 retained images. Learning rate 1e-5 and epoch 28 were selected on the official validation split. Images whose highest vote is neutral or contempt (ties included) are excluded, so these scores are not comparable with the eight-class FER+ benchmark.

Limitations

  • Every driver appears in every training fold, so the scores describe drivers seen during training, not new drivers, cameras or cars.
  • KMU-FED has no per-frame lighting or occlusion labels, so accuracy under those conditions could not be measured separately.
  • Time and memory were measured during training only; inference speed on in-vehicle hardware was not measured.

Use a checkpoint

Use Python 3.11 and the bundled loader for these custom PyTorch checkpoints. From a fresh working directory, download only the inference support files:

python -m pip install "huggingface_hub>=0.25,<1"
python - <<'PY'
from huggingface_hub import snapshot_download
snapshot_download(
    "headless-start/parameter-efficient-dfer",
    allow_patterns=["load_weights.py", "requirements.txt"],
    local_dir="dfer_weights",
    token=False,
)
PY
python -m pip install -r dfer_weights/requirements.txt
import sys
import torch
from PIL import Image

sys.path.insert(0, "dfer_weights")
from load_weights import CLASS_NAMES, build_transform, load_stage2

model = load_stage2("lora", fold=0)  # CPU; device="cuda" for a GPU
with Image.open("face_crop.jpg") as image:
    x = build_transform()(image.convert("RGB")).unsqueeze(0)
with torch.inference_mode():
    probabilities = model(x).softmax(dim=1)[0]
print(CLASS_NAMES[probabilities.argmax().item()])

load_stage1() loads the FER+ model. load_stage2(method, fold) accepts full_ft, linear_probe, adaptformer or lora, with zero-based folds 0–9, and loads the selected configuration. Pass config to load any other candidate of the search, for example load_stage2("lora", fold=0, config="lora__lr1.0e-03__rank0016"); the configuration ids are the folder names under stage2/<method>/candidates/. Both functions accept device and revision keyword arguments; pin a Hub commit with revision="<commit-sha>" for repeatable downloads. Models return in evaluation mode; move input tensors to the same device as the model.

Class order: angry, disgust, fear, happy, sad, surprise. Input must already be a face crop, such as the MTCNN crops that preprocess_kmufed.py in the code repository writes. The transform produces three-channel greyscale, bicubic 224 × 224 resizing and mean/std 0.5 normalisation. Softmax values are uncalibrated model scores. The command-line equivalent is:

python dfer_weights/load_weights.py face_crop.jpg --method lora --fold 0

Files and model details

181 checkpoints: the selected FER+ model and all ten folds of every KMU-FED configuration searched (3 for full fine-tuning, 3 for the linear probe, 6 for AdaptFormer, 6 for LoRA). Of the 183 models trained for the thesis, only the two rejected Stage-1 learning rates were not kept. No dataset images are distributed.

Path Contents
stage1/ Complete model (~343 MB), test results, per-image test predictions and learning-rate study
stage2/<method>/fold_00/ … fold_09/ The selected configuration: weights, results.json (including SHA-256 and the training history) and per-image predictions.json
stage2/<method>/candidates/<config>/fold_00/ … fold_09/ The same three files for every configuration of the search, the selected one included
stage2/<method>/selection.json, search_summary.json Selected settings and candidate scores
load_weights.py, requirements.txt Standalone inference and dependencies

Full fine-tuning stores complete models (~343 MB each). The other strategies store only their trained parameters, head included: linear probe ~22 KB, AdaptFormer 149 KB to 4.8 MB and LoRA 628 KB to 4.8 MB, depending on capacity. Their loader also downloads the Stage-1 model once and reuses it from the local cache. AdaptFormer uses a parallel MLP adapter, width 64 when selected (bottleneck in configuration ids), scale 0.1 and dropout 0.1; LoRA adapts Q/V in all 12 blocks with rank 4 when selected and alpha/r = 2. The fold-k checkpoint never saw the 110 frames held out in fold k (its predictions.json lists them); no checkpoint was trained on all of KMU-FED. All Stage-2 strategies use AdamW, batch size 32 and a 60-epoch budget, with two warm-up epochs and cosine decay.

Licence and citation

Weights: CC BY-NC 4.0. Dataset and pretrained-model terms remain with their providers. Intended for research on adapting expression recognition models; not validated for in-vehicle safety functions or for decisions about individuals.

@mastersthesis{tiwari2026peft_dfer,
  author = {Ayush Tiwari},
  title = {Parameter-Efficient Adaptation of Facial Expression Recognition Models for Driver Monitoring},
  school = {Brandenburgische Technische Universit{\"a}t Cottbus-Senftenberg},
  year = {2026},
  url = {https://github.com/headless-start/parameter-efficient-dfer}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for headless-start/parameter-efficient-dfer

Adapter
(2)
this model