/ Модель

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

Лицензия
CC BY-NC-ND 4.0
Библиотека
keras
Опубликована
14 окт 2026

face-mask-inceptionv3-mtcnn

Классификация изображенийИзображение → label
18скачиваний за 30 дней0лайковвеса обновлены14 окт 2026

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

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

Классификатор обрезанных лиц на InceptionV3 определяет, надета ли маска, отсутствует ли она или надета неправильно.

Модель Jane Rose Ferdinant — классификатор обрезанных изображений лиц для определения наличия маски. Это второй этап двухэтапного конвейера: MTCNN обнаруживает лица, после чего классификатор присваивает каждому обрезанному лицу один из классов: «в маске», «без маски» или «маска надета неправильно». Модель предназначена для учебных проектов, демонстраций и сравнения с другими базовыми решениями.

Архитектура основана на InceptionV3 с весами ImageNet: слои заморожены до mixed7, а сверху добавлена обучаемая классификационная голова с полносвязными слоями и выходом на три класса. Всего у модели 21 562 275 параметров. Она принимает одно RGB-изображение лица размером 100 × 100 пикселей со значениями пикселей, нормализованными в диапазон 0–1, и выдаёт метку класса.

На тестовой выборке из 407 обрезанных лиц из одного набора данных точность составила 96,31%, однако это результат одного запуска и одного разбиения. Класс неправильно надетой маски представлен слабо и распознаётся ненадёжно; модель также зависит от того, насколько хорошо MTCNN обнаруживает лица, и может ошибаться на изображениях с условиями, отличающимися от обучающих. Она не оценивает эффективность маски или соблюдение требований и не предназначена для наблюдения, контроля доступа, решений о людях или задач, критичных для безопасности. Лицензия — CC BY-NC-ND 4.0.

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

  • демонстрация конвейера обнаружения и классификации лиц в масках
  • учебный проект по transfer learning на InceptionV3
  • классификация обрезанного лица по трём категориям ношения маски
  • базовая модель для сравнения классификаторов масок

Ограничения

Класс неправильно надетой маски представлен всего 12 примерами в тестовой выборке и распознаётся ненадёжно; оценка основана на одном запуске и одном публичном наборе данных. Модель зависит от обнаружения лиц MTCNN, подвержена переобучению и не подходит для надзора, принудительного контроля или решений о людях.

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

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

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

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

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

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

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

Открыть на Hugging Face

Face-mask classifier: InceptionV3 transfer learning (for use after MTCNN)

A small Keras image classifier that looks at one cropped face and labels it with_mask, without_mask or mask_weared_incorrect. It is the second stage of a two-stage pipeline: MTCNN finds the faces, each face is cropped, and this model classifies the crop. It is a teaching and demonstration model, not a production system.

Model details

ArchitectureInceptionV3 with ImageNet weights, all layers frozen and cut at layer mixed7, then Flatten, Dense 1024, Dropout 0.3, Dense 3 (softmax)
Parameters21,562,275 in total, 12,587,011 trainable (the new head only)
Inputone face crop, RGB, resized to 100 x 100 pixels, pixel values scaled to 0-1 (divide by 255)
Outputsoftmax over 3 classes: 0 without_mask, 1 with_mask, 2 mask_weared_incorrect
TrainingAdam, categorical cross-entropy, 20 epochs, batch size 32, seed 42, CPU only (about 5 minutes)
SoftwarePython 3.11.9, TensorFlow 2.21.0, Keras 3.15.1

Files

FileWhat it is
inceptionV3-model.kerasThe final epoch-20 model, full Keras model. This is the model the results below describe, and the one the demo uses.
best-model.weights.h5Weights of the best-validation checkpoint (epoch 10), weights only: build the same architecture first, then load_weights. Secondary result in the run log; not used by the demo.
run_metrics.jsonSeed, split sizes, per-class precision/recall/F1, confusion matrices and training history of the run.

Training and evaluation data

Kaggle Face Mask Detection by andrewmvd, CC0 1.0 (the images and annotations come from the Make ML Mask Dataset): 853 photos, 4,072 annotated faces. Classes: with_mask 3,232 (79.4%), without_mask 717 (17.6%), mask_weared_incorrect 123 (3.0%).

The split is made by source photo (seed 42, so no photo and none of its byte-identical duplicates appears in two splits): train 3,299 face crops from 700 photos, validation 366 from 70, test 407 from 78.

The dataset shows real people's faces. CC0 describes the dataset's copyright status; it does not say whether the people shown consented to being in it.

Results

MetricValueStatusHow measured
Test accuracy0.9631 (392 of 407 face crops)Verified (re-run 2026-10-13, photo-grouped split)model.evaluate on the 78 held-out photos, final epoch-20 model, seed 42
Majority-class baseline0.7936Verified (re-run 2026-10-13, photo-grouped split)always predicting with_mask on the same test set
ClassPrecisionRecallF1Test crops
without_mask0.9560.9030.92972
with_mask0.9670.9910.979323
mask_weared_incorrect0.8750.5830.70012
macro average0.9330.8260.869407

This is one run, on one split, with no confidence interval. An older notebook output from February 2022 reported 94.85% on a different, unseeded random split by face; the two numbers are different measurements on different test sets and are not directly comparable. Details: run log.

Limitations

  • The rarest class is unreliable. mask_weared_incorrect has only 12 test crops; one crop moves its recall by about 8 points, and its F1 is 0.70 (7 of 12 found).
  • Small, single-source data. 853 photos from one public dataset. It has not been tested on other cameras, lighting, face angles, skin tones or mask styles, and it will make mistakes on photos unlike the training data.
  • The detector misses faces. The model only sees what MTCNN passes to it. In one local test photo MTCNN found 5 of the 9 faces, and a missed face gets no label at all.
  • Overfitting. Validation loss rises from 0.28 at epoch 1 to 0.80 at epoch 20; the headline model is the last epoch, as in the original notebook.
  • Not a measure of compliance. A "mask" label says a mask-like object is on the crop, not that it is worn correctly or is effective.

Intended use

Teaching, coursework and demonstrations of a two-stage detect-then-classify vision pipeline, and as a baseline to compare against.

Out of scope: safety-critical decisions, health or compliance enforcement, access control, surveillance, or any decision about a person. Do not use it to identify or track individuals.

How to use

import cv2, numpy as np
from huggingface_hub import hf_hub_download
from keras.models import load_model
from mtcnn import MTCNN

path = hf_hub_download("JaneRoseFerdinant/face-mask-inceptionv3-mtcnn", "inceptionV3-model.keras")
model = load_model(path, compile=False)
labels = {0: "without_mask", 1: "with_mask", 2: "mask_weared_incorrect"}

rgb = cv2.cvtColor(cv2.imread("photo.jpg"), cv2.COLOR_BGR2RGB)
for face in MTCNN().detect_faces(rgb):
    x, y, w, h = face["box"]
    x, y = max(0, x), max(0, y)
    crop = cv2.resize(rgb[y:y + h, x:x + w], (100, 100)).astype("float32") / 255.0
    probs = model.predict(crop[None], verbose=0)[0]
    print(face["box"], labels[int(probs.argmax())], round(float(probs.max()), 3))

Use the pinned versions from the repository (requirements.txt, Python 3.11, TensorFlow 2.21, Keras 3.15.1, mtcnn 1.0.0) for results that match the run log.

License

The original work in this repository (the model weights and the card) is (c) Jane Rose Ferdinant, licensed under CC BY-NC-ND 4.0. Third-party components keep their own licenses: the training data is CC0, the InceptionV3 architecture and ImageNet starting weights come from Keras, and mtcnn is MIT. See THIRD_PARTY_NOTICES.md in the GitHub repository.

Citation and credits

  • Dataset: Kaggle "Face Mask Detection" by andrewmvd (CC0), from the Make ML Mask Dataset.
  • MTCNN: Zhang, K., Zhang, Z., Li, Z. and Qiao, Y., "Joint Face Detection and Alignment Using Multitask Cascaded Convolutional Networks", IEEE Signal Processing Letters, 2016.
  • InceptionV3: Szegedy, C. et al., "Rethinking the Inception Architecture for Computer Vision", CVPR 2016.

Author

Jane Rose Ferdinant · Portfolio · LinkedIn

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

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

GPU в ailist

Универсальный рантайм · keras

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

Keras/TensorFlow-модели рантайм не загружает.

Ревизия весов
fefc6fd

0 моделей