MCPcopy Index your code
hub / github.com/amirhfarzaneh/dacl

github.com/amirhfarzaneh/dacl @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
61 symbols 156 edges 6 files 5 documented · 8%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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. | | method | backbone | affectnet acc. | rafdb acc. | url | logs | size | |---|--------------|----------|:--------------:|:----------:|:-----------:|:----:| | 0 | DACL | resnet18 | 65.20 % | 87.78 % | soon | NA | | 1 | center loss | resnet18 | 64.09 % | 87.06 % | soon | NA | | 2 | softmax loss | resnet18 | 63.86 % | 86.54 % | soon | NA |

Usage

  1. Install the required dependencies:
- 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:
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}
}

Core symbols most depended-on inside this repo

update
called by 10
utils.py
_resnet
called by 9
models/resnet.py
_make_layer
called by 4
models/resnet.py
conv3x3
called by 3
models/resnet.py
conv1x1
called by 3
models/resnet.py
accuracy
called by 2
utils.py
calc_metrics
called by 2
utils.py
close
called by 2
utils.py

Shape

Method 31
Function 20
Class 10

Languages

Python100%

Modules by API surface

utils.py23 symbols
models/resnet.py22 symbols
loss.py7 symbols
main.py5 symbols
workspace.py4 symbols

For agents

$ claude mcp add dacl \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact