Downloads · 30 days
143
59% of all-time downloads
michaelgathara/vit-face-raf-db
vit-face-raf-db is a image classification model from michaelgathara. Use it when you need a label for an image. It is set up for transformers.
This model is a fine-tuned version of trpakov/vit-face-expression on the RAF-DB (Real-world Affective Faces Database).
Downloads · 30 days
143
59% of all-time downloads
All-time downloads
243
Public
Parameters
85.8M
1 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt687 MB · 50%
From the Hugging Face model README
This model is a fine-tuned version of trpakov/vit-face-expression on the RAF-DB (Real-world Affective Faces Database).
RAF-DB is a large-scale facial expression database with around 30,000 facial images downloaded from the Internet. The images cover 7 basic emotions and 12 compound emotions. This model was fine-tuned on the 7 basic emotions subset.
from transformers import ViTImageProcessor, ViTForImageClassification
from PIL import Image
import requests
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
repo_name = "michaelgathara/vit-face-raf-db"
processor = ViTImageProcessor.from_pretrained(repo_name)
model = ViTForImageClassification.from_pretrained(repo_name)
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
# model predicts one of the 7 emotions
predicted_class_idx = logits.argmax(-1).item()
print("Predicted class:", model.config.id2label[predicted_class_idx])