File size: 2,101 Bytes
a070ac5
 
 
 
 
 
 
 
 
 
 
 
 
a2b8ca5
 
1e38540
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
license: mit
datasets:
- Dc-4nderson/feelings_classfication_dataset
language:
- en
base_model:
- google/vit-base-patch16-224-in21k
pipeline_tag: image-classification
library_name: transformers
tags:
- emotions
- school
metrics:
- accuracy
---
# 🤖 ViT Emotion Classifier

This is a lightweight [Vision Transformer (ViT)](https://huggingface.co/docs/transformers/model_doc/vit) model fine-tuned to classify **emotions** from facial images using a custom dataset of school-aged individuals. It supports 8 emotional categories and is designed to work well on small datasets and limited compute.

---

## 🧠 Supported Emotions

The model predicts one of the following emotional states:

| Label ID | Emotion            |
|----------|--------------------|
| 0        | anxious-fearful    |
| 1        | bored              |
| 2        | confused           |
| 3        | discouraged        |
| 4        | frustrated         |
| 5        | neutral            |
| 6        | positive           |
| 7        | suprised           |

---

## 📦 Model Details

- **Model Type**: `ViTForImageClassification`
- **Backbone**: `vit-small-patch16-224`
- **Dataset**: [`Dc-4nderson/feelings_classfication_dataset`](https://huggingface.co/datasets/Dc-4nderson/feelings_classfication_dataset)
- **Framework**: PyTorch
- **Labels**: 8 emotions (defined in `config.json`)
- **Trained on**: Google Colab with < 600 images

---

## 🧪 Usage

```python
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
import torch

# Load model + processor
processor = AutoImageProcessor.from_pretrained("Dc-4nderson/vit-emotion-classifier")
model = AutoModelForImageClassification.from_pretrained("Dc-4nderson/vit-emotion-classifier")

# Load image and preprocess
image = Image.open("your_image.jpg").convert("RGB")
inputs = processor(images=image, return_tensors="pt")

# Run inference
with torch.no_grad():
    outputs = model(**inputs)
    pred = torch.argmax(outputs.logits, dim=1).item()
    label = model.config.id2label[str(pred)]

print("🧠 Predicted Emotion:", label)