fer-mek-checkpoints / README.md
ToiTenBao's picture
Upload README.md with huggingface_hub
94cc6fb verified
|
Raw
History Blame Contribute Delete
2.71 kB
---
license: mit
tags:
- facial-expression-recognition
- image-classification
- pytorch
- resnet
- imbalanced-classification
library_name: pytorch
---
# FER / MEK checkpoints (ResNet-18/34)
7-class facial-expression recognition checkpoints for **MEK** (*Mine Extra Knowledge*,
Zhang et al., NeurIPS 2023, [arXiv:2310.19636](https://arxiv.org/abs/2310.19636))
re-implemented on torchvision ResNet-18/34. Trained and evaluated on **RAF-DB** and
**FER-2013** under a leakage-free validation protocol (config selected on a 10% val split;
test reported only). Headline metric: **mean-class accuracy** (unweighted mean of per-class
recalls), the right objective under severe class imbalance.
Code: <https://github.com/frichickens/CV-Project-HUST>.
## Checkpoints
| File | Description | Test acc | Mean-class | Backbone |
|---|---|:-:|:-:|:-:|
| `mek_resnet18_rafdb_msceleb_best.pth` | RAF-DB - MEK ResNet-18 - MS-Celeb-1M backbone (headline best, verified) | 0.8641 | 0.8137 | MS-Celeb-1M |
| `mek_resnet18_rafdb_imagenet_best.pth` | RAF-DB - MEK ResNet-18 - ImageNet backbone | 0.8585 | 0.7910 | ImageNet |
| `mek_resnet34_rafdb_imagenet_best.pth` | RAF-DB - MEK ResNet-34 - ImageNet backbone (best overall acc) | 0.8657 | 0.7892 | ImageNet |
| `mek_resnet34_fer2013_imagenet_best.pth` | FER-2013 - MEK ResNet-34 - ImageNet backbone (best FER, verified) | 0.7205 | 0.6960 | ImageNet |
| `mek_resnet18_fer2013_imagenet_best.pth` | FER-2013 - MEK ResNet-18 - ImageNet backbone | 0.7081 | 0.6928 | ImageNet |
| `mek_webcam_resnet18_rafdb_clahe_facecrop_best.pth` | RAF-DB - webcam-robust MEK ResNet-18 - MS-Celeb-1M + EMA + face-crop/CLAHE (demo.py) | 0.8625 | 0.8083 | MS-Celeb-1M |
All files are `MEKResNet` `state_dict`s (7 classes, 224x224 input). The `rafdb_msceleb`
and `fer_rn34` checkpoints are end-to-end **verified**: re-running them reproduces the
reported overall / mean-class / per-class accuracy to four decimals.
## Usage
```python
import torch
from huggingface_hub import hf_hub_download
from mek.model import MEKResNet # from the project repo
path = hf_hub_download("ToiTenBao/fer-mek-checkpoints", "mek_resnet18_rafdb_msceleb_best.pth")
model = MEKResNet("resnet18", num_classes=7, pretrained=False)
model.load_state_dict(torch.load(path, map_location="cpu", weights_only=True))
model.eval()
logits, attn = model(images) # images: [B,3,224,224], ImageNet-normalised
```
RAF-DB class index -> emotion: `0`=surprise `1`=fear `2`=disgust `3`=happy `4`=sad
`5`=angry `6`=neutral (folders `1..7` sorted as strings). FER-2013 classes are the folder
names in alphabetical order: angry, disgust, fear, happy, neutral, sad, surprise.