/ Модель

Характеристики

Лицензия
MIT
Библиотека
tf-lite
Опубликована
29 авг 2026

maternalink-fer-mobilenetv2

Классификация изображенийИзображение → label3 профессии
36скачиваний за 30 дней0лайковвеса обновлены29 авг 2026

Описание модели

Составлено на русском по карточке модели и метаданным Hugging Face

Модель MobileNetV2 в формате TensorFlow Lite оценивает вероятности семи выражений лица на заранее обрезанном изображении.

MaternaLink FER — MobileNetV2 — это модель распознавания выражений лица, разработанная для исследовательского проекта MaternaLink по поддержке беременных. Она дообучена на FER-2013 и экспортирована в TensorFlow Lite с калибровкой вероятностей методом temperature scaling. На вход подаётся заранее обрезанное изображение лица размером 96×96; модель выдаёт вероятности семи классов выражений: злость, отвращение, страх, радость, нейтральное выражение, грусть и удивление. Обнаружение лица не входит в модель, поэтому подготовка кадра и корректное кадрирование остаются задачей вызывающего приложения.

Модель подходит для исследовательских экспериментов и как вспомогательный сигнал в системе с несколькими источниками данных. Заявленная точность составляет 62,9%; классы злости, отвращения, страха и грусти часто смешиваются, а результат зависит от освещения. Данные FER-2013 имеют демографический перекос, и применимость к целевой аудитории проекта в Шри-Ланке не проверена. Выражение лица не позволяет надёжно определить эмоцию, настроение или психологическое состояние. Модель не предназначена для медицинской оценки, диагностики, скрининга, найма, наблюдения, безопасности или автономных решений, влияющих на людей. Лицензия — MIT.

Сценарии применения

  • оценка выражений лица на подготовленных изображениях в исследовательских экспериментах
  • сравнение вероятностей семи классов FER-2013
  • добавление классификации выражений как вспомогательного сигнала в многосигнальную систему

Ограничения

Точность составляет 62,9%; отрицательные классы выражений заметно смешиваются, а качество ухудшается при слабом освещении. Лицо нужно обрезать заранее; переносимость на пользователей из Шри-Ланки не проверена, поэтому модель нельзя использовать для выводов об эмоциях или психологическом состоянии и для решений, влияющих на людей.

Публичные бенчмарки

Результаты из открытых лидербордов в сравнении с лидерами каталога

Публичных оценок пока нет

В подключённых источниках результатов этой модели не нашлось. Отсутствие оценки не значит, что модель хуже: её могли просто не проверять.

Источники: Hugging Face Leaderboards, Hugging Face Eval Results, Open LLM v2, MTEB, timm, Open ASR, EvalPlus, LLM Stats

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

MaternaLink FER — MobileNetV2, 7-class calibrated

Facial expression recognition for the MaternaLink pregnancy-support research project (IT22638168). Fine-tuned MobileNetV2, exported to TensorFlow Lite, with temperature-scaled (calibrated) probabilities.

⚠️ This is not a diagnostic tool

It estimates facial expression from a single image. It does not measure emotion, mood, wellbeing, or any mental-health state, and it must never be presented as a medical, clinical, or psychological assessment.

Accuracy is 62.9%. Roughly one prediction in three is wrong.


What it outputs

Seven calibrated probabilities, summing to 1.0, in this exact order:

0 angry   1 disgust   2 fear   3 happy   4 neutral   5 sad   6 surprise

What it does NOT do

not includedwhybelongs
face detectionexpects a pre-cropped faceMediaPipe BlazeFace, upstream
CALM / NEUTRAL / DISTRESSED outputthe 7→3 mapping is an undecided application-level decisiondownstream, later
temporal smoothingundecidedapplication layer
confidence gatingundecidedapplication layer

This model outputs 7 FER classes. It does not output CALM / NEUTRAL / DISTRESSED.

It does not detect faces. Given a full uncropped frame it returns seven plausible-looking probabilities that are meaningless, and nothing in the output signals this. Cropping correctly is entirely the caller's responsibility.


Files

filesizeSHA-256use
fer_mobilenetv2_96_float32.tflite8,956,864 B47b3adcc0ce769afa469ec6dd272e2561263863ab73621a449fcc1340e958c8cserver / x86 — recommended
fer_mobilenetv2_96_float16.tflite4,578,244 Ba83946afed5043953d03a00eb239c8cc3584fe9f28eed74ba7ac9456a79ca78dmobile candidate
fer_mobilenetv2_96_dynint8.tflite2,572,184 B3fbe843e46a59f879300715207a73fb912a1fb6ffe98984dc4c5ca55e2f4f2ecmobile candidate
nb07_tensor_spec.json——machine-readable tensor contract

A full-integer int8 variant exists and is deliberately NOT published — it lost 0.1188 macro-F1 (18× the project's measured noise floor), its calibration collapsed (ECE 0.1443), and it was larger than dynint8. It is strictly dominated and must not be used.

Which variant

float32 for server-side inference. On x86 it was measured as both the most accurate and the fastest (1.78 ms vs float16's 2.62 ms mean); x86 has no native fp16 compute, so float16 is dequantized at runtime. File size is irrelevant on a server.

The mobile variant is undecided. float16 is provisional but assumes ARM hardware fp16, which has not been measured — no on-device benchmark has been run. Do not treat the x86 latency figures as predictive for ARM.

variantval macro-F1ECEagreement with the validated model
float320.61220.009999.5%
float160.60900.013599.0%
dynint80.60710.010391.5% — ~1 prediction in 12 differs

All three are within the project's measured noise floor (0.0065 macro-F1) on aggregate accuracy. dynint8's per-frame disagreement is much larger than its aggregate metrics suggest — a distinction aggregate numbers alone would have hidden.


Tensor contract

inputfloat32, shape (1, 96, 96, 3), values in [-1, 1]
outputfloat32, shape (1, 7), calibrated softmax

Preprocessing — exact, and not negotiable

1. decode as single-channel grayscale
2. resize to 48×48   (bilinear → round → uint8)
3. replicate grayscale to 3 channels
4. resize to 96×96   (bilinear, IN FLOAT32)
5. scale [0,255] → [-1,1]   (x / 127.5 - 1.0)

Step 2 is not redundant. The model was trained only on FER-2013, whose images are 48×48. A live camera crop carries far more detail than anything in its training distribution; downsampling to 48×48 first discards that surplus so live input matches training. Removing this step is a silent distribution shift.

Step 4 must be done in float32. Resizing as uint8 rounds every interpolated pixel to an integer grey level, which diverges from the reference by up to 1.0 grey level. That sounds negligible — it is not. Because the model is calibrated (see below), a 0.4%-of-range input difference produced a 0.135 probability difference and flipped 2.1% of predictions in testing. With float32 resizing the divergence is exactly zero.


Calibration

Probabilities are temperature-scaled, fitted on validation and baked into the exported graph. Do not apply temperature again.

beforeafter
Expected Calibration Error0.30100.0126
temperature—T = 5.727
predictions changed—0 / 3,589

Calibration is argmax-invariant, so every accuracy figure below remains exactly valid.

Before calibration the model claimed 99% confidence while being right 70% of the time. The confidence output is now a usable probability — but it is a model-certainty estimate, not a measure of emotional intensity.

Side effect worth knowing: calibration flattens the distribution, which makes the model more sensitive to small input perturbations. Preprocessing must be exact.


Performance

Test macro-F10.6036
Test accuracy0.6289
test splitFER-2013 PrivateTest, 3,589 images, touched exactly once
generalisation gap−0.0085 macro-F1

Per-class F1:

classF1classF1
happy0.844angry0.523
surprise0.733sad0.484
neutral0.599fear0.475
disgust0.568

Training used a de-duplicated, leakage-free FER-2013 train split (26,901 images). The test split was contacted once, with no tuning afterwards. The near-zero generalisation gap indicates the validation-driven selection protocol did not overfit.

For context, ~65% is the commonly cited human benchmark on FER-2013 and ~73% the published state of the art.


Verification

The exported artifact was verified against the pipeline that produced the published metrics:

  • Preprocessing parity — the reference implementation reproduces the training-time TensorFlow pipeline bit-identically: max tensor difference exactly 0.0 across 99,228,672 elements over all 3,589 validation images, argmax agreement 1.0000.
  • Service parity — an HTTP inference wrapper was verified to preserve those numbers (max deviation 4.99e-7, entirely attributable to 6-decimal response rounding; argmax 100/100).
  • Runtime equivalence — ai-edge-litert vs tf.lite: max probability difference 2.98e-8 (float32 epsilon), argmax 60/60.

Limitations — read before using any output

  1. Demographic skew. FER-2013 is predominantly Western/Caucasian. MaternaLink targets Sri Lankan users, and external validity for that population is unvalidated. This is the most serious limitation of this model.
  2. Negative expressions are poorly separated. angry, disgust, fear and sad confuse heavily with one another (F1 ≈ 0.47–0.57). happy (0.84) and surprise (0.73) separate cleanly; the negative group is not individually trustworthy. Do not build logic that distinguishes between them.
  3. Low source resolution. 48×48 grayscale. Fine facial detail is unavailable to the model.
  4. Lighting sensitivity. In the darkest decile of images macro-F1 falls to 0.457 against 0.644 in the brightest — minority classes degrade far more than accuracy alone suggests.
  5. Single-frame only. No temporal context.
  6. Expression ≠ emotion. A person may display an expression that does not reflect their internal state. The model observes appearance only.
  7. Label noise. FER-2013 contains conflicting labels, imposing an accuracy ceiling independent of model quality.

Explainability

Grad-CAM analysis found the model attends to central face regions, never to image corners, backgrounds or watermarks, and that attention is unchanged on errors — failures are genuine expression-discrimination failures, not attention failures. It does not use per-class brightness as a shortcut. Feature-map resolution is 3×3, so only centre-vs-edge and upper-vs-lower conclusions are supportable.

Intended and out-of-scope use

Intended: research; a single auxiliary evidence channel in a multi-signal system, behind appropriate safeguards.

Out of scope: any clinical, diagnostic, screening, hiring, surveillance, or security-adjacent use; any autonomous decision affecting a person; any use where a raw class label is shown to a user as a statement about their emotional state.


Usage

import numpy as np
from PIL import Image
from ai_edge_litert.interpreter import Interpreter   # or tflite_runtime / tf.lite

CLASSES = ["angry", "disgust", "fear", "happy", "neutral", "sad", "surprise"]

def preprocess(img):                       # img: a PIL image of a CROPPED FACE
    gray   = img.convert("L")
    arr48  = np.asarray(gray.resize((48, 48), Image.BILINEAR), dtype=np.uint8)
    f      = Image.fromarray(arr48.astype(np.float32), mode="F")     # float32 — required
    a96    = np.asarray(f.resize((96, 96), Image.BILINEAR), dtype=np.float32)
    x      = np.stack([a96, a96, a96], axis=-1) / 127.5 - 1.0
    return np.expand_dims(x, 0).astype(np.float32)

itp = Interpreter(model_path="fer_mobilenetv2_96_float32.tflite")
itp.allocate_tensors()
inp, out = itp.get_input_details()[0], itp.get_output_details()[0]

itp.set_tensor(inp["index"], preprocess(Image.open("face_crop.jpg")))
itp.invoke()
probs = itp.get_tensor(out["index"])[0]

print(dict(zip(CLASSES, probs.round(4))), "->", CLASSES[int(np.argmax(probs))])

Provenance

architectureMobileNetV2 (α=1.0, ImageNet init), fine-tuned
parameters2,266,951 (1,848,583 trainable)
input resolution96×96 (from 48×48 source)
training dataFER-2013, de-duplicated train split, 26,901 images
exportTensorFlow 2.21.0 / Keras 3.15.1

No dataset images are distributed with this model.

Licence

MIT for the exported model artifacts and code. FER-2013 carries its own terms; users are responsible for compliance with the dataset licence for any training or redistribution of derived data.

Citation

Undergraduate research project IT22638168 (MaternaLink), 2026. Facial expression recognition as one evidence channel in a bilingual pregnancy-support conversational system.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · tf-lite

Нельзя запустить

Библиотека «tf-lite» рантаймом не поддерживается.

Ревизия весов
4e6c13b

0 моделей