facial_emotion / README.md
sreenathsree1578's picture
Update README.md
d367457 verified
# Facial Emotion Recognition – SimpleCNN
A lightweight convolutional neural network (CNN) for **facial emotion recognition**.
The model is trained to classify grayscale facial images into **7 emotion categories**.
## Model Details
- **Model type:** SimpleCNN (custom lightweight CNN)
- **Framework:** PyTorch
- **Task:** Image Classification
- **Input shape:** 1 Γ— 48 Γ— 48 (grayscale image)
- **Number of classes:** 7
- **Classes:**
- 0 β†’ Angry
- 1 β†’ Disgust
- 2 β†’ Fear
- 3 β†’ Happy
- 4 β†’ Sad
- 5 β†’ Surprise
- 6 β†’ Neutral
## Intended Uses & Limitations
- βœ… Educational projects, demos, prototypes.
- ❌ Not suitable for medical, psychological, or safety-critical applications.
- ❌ May not generalize well outside datasets like FER2013.
## How to Use
```python
from huggingface_hub import hf_hub_download
import torch
import json
from facial_emotion import SimpleCNN # your model class
# Load config
config = json.load(open("config.json"))
# Build model
model = SimpleCNN(num_classes=config["num_classes"], in_channels=config["in_channels"])
# Load weights
checkpoint = hf_hub_download(repo_id="sreenathsree1578/facial_emotion", filename="pytorch_model.bin")
model.load_state_dict(torch.load(checkpoint, map_location="cpu"))
model.eval()
# Example inference
dummy = torch.randn(1, 1, 48, 48) # dummy grayscale image
with torch.no_grad():
out = model(dummy)
pred = torch.argmax(out, dim=1).item()
print("Predicted emotion:", config["labels"][str(pred)])