Instructions to use pelikrapael/vit-base-elderly-emotion-recognition with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pelikrapael/vit-base-elderly-emotion-recognition with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="pelikrapael/vit-base-elderly-emotion-recognition") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("pelikrapael/vit-base-elderly-emotion-recognition") model = AutoModelForImageClassification.from_pretrained("pelikrapael/vit-base-elderly-emotion-recognition", device_map="auto") - Notebooks
- Google Colab
- Kaggle
ViT-Base Elderly Emotion Recognition π΅π§
Fine-tuned Vision Transformer (ViT-base-patch16-224) for recognizing emotional expressions specifically in senior citizens / elderly individuals.
Developed as part of the undergraduate thesis at Gunadarma University (Department of Informatics, 2025) by Felix Rafael under the supervision of Dr. Guntur Eka Saputra, S.T., M.M.S.I.
- Audio Complement (1D-CNN): pelikrapael/audio-cnn-elderly-emotion-recognition
π Model Overview
| Property | Details |
|---|---|
| Base Architecture | Vision Transformer (google/vit-base-patch16-224-in21k) |
| Input Resolution | 224 Γ 224 pixels (RGB) |
| Number of Parameters | ~86 Million |
| Target Population | Elderly / Senior Citizens (Age 60+) |
| Target Classes | 5 Emotions: Angry, Fear, Happy, Neutral, Sad |
| Evaluation Accuracy | 92.00% on held-out elderly test set |
Elderly facial expressions differ significantly from general-population benchmarks (e.g., FER2013 or AffectNet) due to physiological age factors such as skin laxity, dynamic wrinkles, and altered muscle mobility. This model was fine-tuned specifically to capture subtle elderly facial affect patterns.
π Benchmark & Performance Comparison
In extensive empirical benchmarks documented in the thesis, Vision Transformer (ViT) substantially outperformed classical Convolutional Neural Network architectures on elderly facial expressions:
Model Comparison on Elderly Emotion Dataset
| Architecture | Backbone / Pretrain | Test Accuracy | Macro F1 | Performance Gap vs ViT |
|---|---|---|---|---|
| π₯ ViT-base-patch16 (Ours) | ImageNet-21k | 92.00% | 0.92 | Baseline |
| π₯ ResNet-50 | ImageNet-1k | 59.00% | 0.58 | -33.00% |
| π₯ DenseNet-121 | ImageNet-1k | 57.00% | 0.56 | -35.00% |
| 4οΈβ£ EfficientNet-B0 | ImageNet-1k | 51.00% | 0.49 | -41.00% |
Per-Class Detailed Metrics (ViT-base-patch16)
| Emotion | Precision | Recall | F1-Score |
|---|---|---|---|
| Happy π | 1.00 | 1.00 | 1.00 |
| Neutral π | 0.88 | 1.00 | 0.94 |
| Sad π’ | 0.85 | 0.97 | 0.91 |
| Fear π¨ | 0.90 | 0.90 | 0.90 |
| Angry π | 1.00 | 0.73 | 0.85 |
| Macro Average | 0.93 | 0.92 | 0.92 |
π Training Data & Methodology
The dataset comprises a total of 1,004 curated elderly facial images (854 training, 150 independent held-out test):
- Primary Dataset: Direct observational recordings and guided expression sessions with senior citizen participants in Jakarta and Depok, Indonesia.
- Secondary Datasets: Carefully curated subset from UTKFace and All-Age-Faces (AAF) filtered strictly for subjects aged 60 and older.
Training Configuration
- Optimizer: AdamW (
lr=2e-5, weight decay0.01) - Loss Function: CrossEntropyLoss
- Data Augmentation: RandomHorizontalFlip, ColorJitter, RandomRotation (Β±10Β°), Normalized (
mean=[0.5, 0.5, 0.5],std=[0.5, 0.5, 0.5]).
π» How to Use
import torch
from PIL import Image
from transformers import AutoModelForImageClassification
import torchvision.transforms as transforms
# 1. Load model
repo_id = "pelikrapael/vit-base-elderly-emotion-recognition"
model = AutoModelForImageClassification.from_pretrained(repo_id)
model.eval()
# 2. Preprocess input image
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])
])
image = Image.open("path_to_elderly_face.jpg").convert("RGB")
tensor = transform(image).unsqueeze(0)
# 3. Inference
class_names = ['Angry', 'Fear', 'Happy', 'Neutral', 'Sad']
with torch.no_grad():
logits = model(tensor).logits
probs = torch.softmax(logits, dim=-1)[0]
pred_idx = torch.argmax(probs).item()
print(f"Predicted Emotion: {class_names[pred_idx]} ({probs[pred_idx]*100:.2f}%)")
π Acknowledgments & Credits
Special gratitude and heartfelt appreciation are extended to:
- The Senior Citizen Participants who generously took part in the primary data collection and emotional recording sessions. Their voluntary contributions form the vital foundation of this research.
- Dr. Guntur Eka Saputra, S.T., M.M.S.I., as academic thesis advisor at Gunadarma University, for invaluable technical guidance and direction throughout the development of this project.
- Gunadarma University, Faculty of Industrial Technology, Department of Informatics.
- Curators and authors of the UTKFace (Zhang et al.) and All-Age-Faces (AAF) (Cheng et al.) datasets for making high-quality demographic visual data accessible to the scientific community.
π Citation
If you use this model or refer to the research, please cite:
@misc{rafael2025elderlyemotion,
author = {Felix Rafael and Guntur Eka Saputra},
title = {Multimodal Elderly Emotion Detection System Using Convolutional Neural Network and Vision Transformer},
year = {2025},
publisher = {Gunadarma University},
address = {Jakarta, Indonesia},
note = {Undergraduate Thesis, Department of Informatics, Faculty of Industrial Technology}
}
- Downloads last month
- 4
Evaluation results
- Test Accuracy (Held-out)self-reported0.920
- Macro Average F1-Scoreself-reported0.920