GitPedia

Dacl

Deep Attentive Center Loss

From amirhfarzaneh·Updated February 5, 2025·View on GitHub·

PyTorch training code and pretrained models for **DACL** (**D**eep **A**ttentive **C**enter **L**oss). We propose an attention network to adaptively select a subset of significant feature elements for enhanced facial expression discrimination. The attention network estimates attention weights across all feature dimensions to accommodate the sparse formulation of center loss to selectively achieve intra-class compactness and inter-class separation for the relevant information in the embedding spa... The project is written primarily in Python, first published in 2020. Key topics include: attention, attentive, center-loss, dacl, emotion.

DACL: Facial Expression Recognition in the Wild via Deep Attentive Center Loss

PyTorch training code and pretrained models for DACL (Deep Attentive Center Loss). We propose an attention network to adaptively select a subset of significant feature elements for enhanced facial expression discrimination. The attention network estimates attention weights across all feature dimensions to accommodate the sparse formulation of center loss to selectively achieve intra-class compactness and inter-class separation for the relevant information in the embedding space.

PWC

DACL
DACL is highly customizable and can be adapted to other problems in computer vision. For more details see Facial Expression Recognition in the Wild via Deep Attentive Center Loss by Amir Hossein Farzaneh and Xiaojun Qi (WACV2021).

Model Zoo

We provide the trained DACL model and other baseline models with softmax loss and center loss in the future.

methodbackboneaffectnet acc.rafdb acc.url | logssize
0DACLresnet1865.20 %87.78 %soonNA
1center lossresnet1864.09 %87.06 %soonNA
2softmax lossresnet1863.86 %86.54 %soonNA

Usage

  1. Install the required dependencies:
bash
- torch == 1.5+ - torchvision == 0.6+ - scikit-learn - tqdm
  1. Download ms-celeb pretrained model for weight initialization: Google Drive Link
  2. clone this repository:
bash
git clone https://github.com/amirhfarzaneh/dacl

Data preparation

  1. Download either affectnet or rafdb dataset and prepare the dataset folder structure as follows:
path/to/fer/dataset/
  train/  # directory containing training images
        00/ # subdirectory containing images from class 0 (neutral)
        01/ # subdirectory containing images from class 1 (happy)
        02/ # subdirectory containing images from class 2 (sad)
        ...
        06/ # subdirectory containing images from class 6 (disgust)
  valid/  # directory containing validation images
        00/ # subdirectory containing images from class 0 (neutral)
        01/ # subdirectory containing images from class 1 (happy)
        02/ # subdirectory containing images from class 2 (sad)
        ...
        06/ # subdirectory containing images from class 6 (disgust)
  1. modify the dataset root_dir in workspace.py at line 14

Training

To train DACL initialized with msceleb weights on a single GPU for 10 epochs run:

python main.py --arch=resnet18 --lr=[LR] --wd=[WD] --bs=[BATCH-SIZE] --epochs=10 --alpha=[ALPHA] --lamb=[LAMBDA]

Citation

If you use this code in your project or research, please cite using the following bibtex:

@InProceedings{Farzaneh_2021_WACV,
    author    = {Farzaneh, Amir Hossein and Qi, Xiaojun},
    title     = {Facial Expression Recognition in the Wild via Deep Attentive Center Loss},
    booktitle = {Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)},
    month     = {January},
    year      = {2021},
    pages     = {2402-2411}
}

Contributors

Showing top 1 contributor by commit count.

View all contributors on GitHub →

This article is auto-generated from amirhfarzaneh/dacl via the GitHub API.Last fetched: 6/15/2026