CoolFace
Modelpublic

martinbadrous/Facial-Recognition-Verification

sourceHugging Facemitupdated 7mo agoView on Hugging Face
1likes
Model Card

๐Ÿ™‚ CNN โ€” Facial Expression Recognition

CNN-based facial expression classifier trained to recognize 7 emotion categories from face images with a clean, reproducible pipeline.

๐Ÿ“Œ Model Summary

PropertyDetails
๐Ÿ—๏ธ ArchitectureCNN (custom)
๐ŸŽฏ TaskImage Classification
๐Ÿ˜€ Classes7 emotions
โš™๏ธ FrameworkPyTorch
๐Ÿ“ Input size48 ร— 48 px (grayscale)
๐Ÿ“œ LicenseMIT

๐Ÿง  Emotion Classes

#Emotion
0๐Ÿ˜  Angry
1๐Ÿคข Disgust
2๐Ÿ˜จ Fear
3๐Ÿ˜„ Happy
4๐Ÿ˜ Neutral
5๐Ÿ˜ข Sad
6๐Ÿ˜ฒ Surprise

๐Ÿš€ How to Use

python
import torch
import torch.nn.functional as F
from torchvision import transforms
from PIL import Image

# Load model
model = torch.jit.load("model.pt", map_location="cpu")
model.eval()

# Preprocessing
transform = transforms.Compose([
    transforms.Grayscale(),
    transforms.Resize((48, 48)),
    transforms.ToTensor(),
    transforms.Normalize([0.5], [0.5]),
])

EMOTIONS = ["Angry", "Disgust", "Fear", "Happy", "Neutral", "Sad", "Surprise"]

# Inference
image = Image.open("face.jpg")
tensor = transform(image).unsqueeze(0)

with torch.no_grad():
    probs = F.softmax(model(tensor), dim=1)[0]

predicted = EMOTIONS[probs.argmax()]
confidence = probs.max().item()

print(f"Prediction: {predicted} ({confidence:.0%})")

๐Ÿ—‚๏ธ Training Data

  • โ€”Base dataset: FER-2013 (Facial Expression Recognition)
  • โ€”Input format: 48ร—48 grayscale face images
  • โ€”Classes: 7 universal emotion categories

โš ๏ธ Limitations

  • โ€”Optimized for frontal face images
  • โ€”Performance may degrade with partial occlusion, extreme lighting, or non-frontal poses
  • โ€”Not intended for surveillance or identity recognition โ€” expression classification only

๐Ÿ”— Related Resources


๐Ÿ‘ค Author

Martin Badrous โ€” Computer Vision & Deep Learning Engineer

![LinkedIn](https://www.linkedin.com/in/martinbadrous) ![GitHub](https://github.com/martinbadrous) ![HuggingFace](https://huggingface.co/martinbadrous)