Downloads · 30 days
99
40% of all-time downloads
onnx-community/face-emotion-detection-ONNX
face-emotion-detection-ONNX is a image classification model from onnx-community. Use it when you need a label for an image. It is set up for transformers.js. The card lists the license as apache-2.0.
This is an ONNX version of abhilash88/face-emotion-detection. It was automatically converted and uploaded using this Hugging Face Space.
Downloads · 30 days
99
40% of all-time downloads
All-time downloads
247
Public
Repo size
796 MB
Likes
1
Public
Click a slice to open those files.
.onnx940 MB · 100%
From the Hugging Face model README
This is an ONNX version of abhilash88/face-emotion-detection. It was automatically converted and uploaded using this Hugging Face Space.
See the pipeline documentation for image-classification: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.ImageClassificationPipeline
This model is a fine-tuned version of google/vit-base-patch16-224 for facial expression recognition on the FER2013 dataset.
The model can classify faces into 7 different emotions:
from transformers import ViTImageProcessor, ViTForImageClassification
from PIL import Image
import torch
# Load model and processor
processor = ViTImageProcessor.from_pretrained('abhilash88/face-emotion-detection')
model = ViTForImageClassification.from_pretrained('abhilash88/face-emotion-detection')
# Load and preprocess image
image = Image.open('path_to_your_image.jpg')
inputs = processor(image, return_tensors="pt")
# Make prediction
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(predictions, dim=-1).item()
# Emotion classes
emotions = ['Angry', 'Disgust', 'Fear', 'Happy', 'Sad', 'Surprise', 'Neutral']
predicted_emotion = emotions[predicted_class]
confidence = predictions[0][predicted_class].item()
print(f"Predicted Emotion: {predicted_emotion} ({confidence:.2f})")
Here are some example predictions on real faces:







Epoch 1: Loss: 0.917, Accuracy: 66.90%
Epoch 2: Loss: 0.609, Accuracy: 69.32%
Epoch 3: Loss: 0.316, Accuracy: 71.55%
The model achieves solid performance on FER2013, which is known to be a challenging dataset due to:
If you use this model, please cite:
@misc{face-emotion-detection,
author = {Abhilash},
title = {ViT Face Emotion Detection},
year = {2025},
publisher = {Hugging Face},
howpublished = {https://huggingface.co/abhilash88/face-emotion-detection}
}
This model is released under the Apache 2.0 License.
Built with ❤️ using Vision Transformers and PyTorch