Update README.md
Browse files
README.md
CHANGED
|
@@ -1,10 +1,50 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Facial Emotion Recognition β SimpleCNN
|
| 2 |
+
|
| 3 |
+
A lightweight convolutional neural network (CNN) for **facial emotion recognition**.
|
| 4 |
+
The model is trained to classify grayscale facial images into **7 emotion categories**.
|
| 5 |
+
|
| 6 |
+
## Model Details
|
| 7 |
+
- **Model type:** SimpleCNN (custom lightweight CNN)
|
| 8 |
+
- **Framework:** PyTorch
|
| 9 |
+
- **Task:** Image Classification
|
| 10 |
+
- **Input shape:** 1 Γ 48 Γ 48 (grayscale image)
|
| 11 |
+
- **Number of classes:** 7
|
| 12 |
+
- **Classes:**
|
| 13 |
+
- 0 β Angry
|
| 14 |
+
- 1 β Disgust
|
| 15 |
+
- 2 β Fear
|
| 16 |
+
- 3 β Happy
|
| 17 |
+
- 4 β Sad
|
| 18 |
+
- 5 β Surprise
|
| 19 |
+
- 6 β Neutral
|
| 20 |
+
|
| 21 |
+
## Intended Uses & Limitations
|
| 22 |
+
- β
Educational projects, demos, prototypes.
|
| 23 |
+
- β Not suitable for medical, psychological, or safety-critical applications.
|
| 24 |
+
- β May not generalize well outside datasets like FER2013.
|
| 25 |
+
|
| 26 |
+
## How to Use
|
| 27 |
+
```python
|
| 28 |
+
from huggingface_hub import hf_hub_download
|
| 29 |
+
import torch
|
| 30 |
+
import json
|
| 31 |
+
|
| 32 |
+
from facial_emotion import SimpleCNN # your model class
|
| 33 |
+
|
| 34 |
+
# Load config
|
| 35 |
+
config = json.load(open("config.json"))
|
| 36 |
+
|
| 37 |
+
# Build model
|
| 38 |
+
model = SimpleCNN(num_classes=config["num_classes"], in_channels=config["in_channels"])
|
| 39 |
+
|
| 40 |
+
# Load weights
|
| 41 |
+
checkpoint = hf_hub_download(repo_id="sreenathsree1578/facial_emotion", filename="pytorch_model.bin")
|
| 42 |
+
model.load_state_dict(torch.load(checkpoint, map_location="cpu"))
|
| 43 |
+
model.eval()
|
| 44 |
+
|
| 45 |
+
# Example inference
|
| 46 |
+
dummy = torch.randn(1, 1, 48, 48) # dummy grayscale image
|
| 47 |
+
with torch.no_grad():
|
| 48 |
+
out = model(dummy)
|
| 49 |
+
pred = torch.argmax(out, dim=1).item()
|
| 50 |
+
print("Predicted emotion:", config["labels"][str(pred)])
|