Emo-AffectNet Face Emotion Recognition โ€” TensorFlow Lite

This repository contains a TensorFlow Lite float32 conversion of the static image face emotion recognition model from ElenaRyumina/face_emotion_recognition.

The model predicts one of seven facial emotion classes from an RGB face image.

Files

File Description
emo_affectnet_static_float32.tflite Converted TensorFlow Lite model.
labels.txt Output labels in model order.
conversion_report.json Conversion metadata and PyTorch-vs-TFLite parity check.
infer_tflite.py Minimal Python inference example.
requirements.txt Python dependencies for the inference example.

Model details

Labels

The output logits use this label order:

  1. Neutral
  2. Happiness
  3. Sadness
  4. Surprise
  5. Fear
  6. Disgust
  7. Anger

Quick start

Install the example dependencies:

pip install -r requirements.txt

Run inference on a face image:

python infer_tflite.py --image path/to/face.jpg

Example output:

{
  "top_label": "Happiness",
  "top_score": 0.9123,
  "predictions": [
    {"label": "Happiness", "score": 0.9123},
    {"label": "Neutral", "score": 0.0531},
    {"label": "Surprise", "score": 0.0214}
  ]
}

Preprocessing

The TFLite model expects:

  1. A face image in RGB order.
  2. Resize to 224 ร— 224 pixels.
  3. Convert to float32.
  4. Keep pixel values in the 0..255 range.
  5. Add a batch dimension to produce shape [1, 224, 224, 3].

Do not normalize to 0..1 unless you reconvert the model with a different input convention.

Conversion validation

The conversion report records a parity check between the converted model and the source PyTorch model:

  • Samples checked: 3
  • Maximum absolute difference: 1.4901161193847656e-06
  • Mean absolute difference: 5.336921825952837e-07
  • Top-1 match rate: 1.0

See conversion_report.json for the full metadata.

Publishing to Hugging Face

This folder is ready to upload as a Hugging Face model repository.

Recommended upload flow:

pip install -U huggingface_hub
hf auth login
hf repos create <namespace>/<repo-name>
hf upload <namespace>/<repo-name> . . --repo-type model --exclude ".serena/*" --exclude "__pycache__/*"

If you publish with Git instead of huggingface-cli upload, install Git LFS first so the .tflite file is stored correctly:

git lfs install
git init
git add .
git commit -m "Add TFLite face emotion recognition model"
git remote add origin https://huggingface.co/<namespace>/<repo-name>
git push -u origin main

Limitations and intended use

  • This model is intended for facial expression recognition research and application prototyping.
  • Predictions can be sensitive to face detection quality, crop alignment, lighting, occlusion, pose, and image quality.
  • Emotion labels are simplified categories and should not be treated as definitive measurements of a person's internal state.
  • Evaluate the model carefully before using it in production or high-impact settings.

Citation

If you use the original Emo-AffectNet model in research, cite the source paper:

@article{RYUMINA2022,
  title   = {In Search of a Robust Facial Expressions Recognition Model: A Large-Scale Visual Cross-Corpus Study},
  author  = {Elena Ryumina and Denis Dresvyanskiy and Alexey Karpov},
  journal = {Neurocomputing},
  year    = {2022},
  doi     = {10.1016/j.neucom.2022.10.013},
  url     = {https://www.sciencedirect.com/science/article/pii/S0925231222012656}
}

License

The source model and original project are licensed under the MIT License. This converted TFLite repository keeps the same license. See LICENSE and NOTICE.md.

Downloads last month
64
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for pat229988/AffectNet-face-to-emotion-tflite

Finetuned
(1)
this model