File size: 1,501 Bytes
09e0768
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---

tags:
- image-classification
- pytorch
- huggingface
- vit
- emotion-recognition
datasets:
- zenodo
- mendeley
- raf-db
- affectnet
base_model: trpakov/vit-face-expression
library_name: transformers
---


# ViT Face Expression (Universal / Combined)

This model is a fine-tuned version of [trpakov/vit-face-expression](https://huggingface.co/trpakov/vit-face-expression) on a massive combined dataset including:
- **Zenodo (IFEED)**
- **Mendeley (GFFD-2025)**
- **RAF-DB**
- **AffectNet**

## Model Description
- **Architecture**: Vision Transformer (ViT)
- **Task**: Facial Emotion Recognition
- **Emotions**: Anger, Disgust, Fear, Happiness, Neutral, Sadness, Surprise
- **Goal**: General-purpose robustness across varied domains (web images, lab settings, etc.)

## Usage

```python

from transformers import ViTImageProcessor, ViTForImageClassification

from PIL import Image

import requests



url = 'http://images.cocodataset.org/val2017/000000039769.jpg'

image = Image.open(requests.get(url, stream=True).raw)



repo_name = "michaelgathara/vit-face-universal"



processor = ViTImageProcessor.from_pretrained(repo_name)

model = ViTForImageClassification.from_pretrained(repo_name)



inputs = processor(images=image, return_tensors="pt")

outputs = model(**inputs)

logits = outputs.logits

# model predicts one of the 7 emotions

predicted_class_idx = logits.argmax(-1).item()

print("Predicted class:", model.config.id2label[predicted_class_idx])

```