fairface age image detection

Providerdima806
Categoryimage-classification
Licenseapache-2.0
Downloads69
Stars0

Overview

The FairFace age detection model is a specialized image classification tool designed to mitigate demographic bias in age estimation. Unlike generic vision models, FairFace is trained on a balanced dataset across multiple ethnic groups, making it a reliable choice for developers building inclusive applications. It integrates easily into standard computer vision pipelines for automated user profiling, KYC verification, or targeted content delivery. For developers, this model offers a lightweight alternative to heavy multi-task transformers when the primary requirement is objective, fair age categorization across diverse global populations.

Highlights

  • Reduced demographic bias for fair global age estimation
  • Optimized for image classification and user profiling
  • Apache-2.0 license ensures flexible commercial integration
  • High reliability across diverse ethnic datasets

Usage

Install
# Install Hugging Face transformers
pip install transformers torch
SDK Usage
# Load model with transformers
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("dima806/fairface_age_image_detection")
tokenizer = AutoTokenizer.from_pretrained("dima806/fairface_age_image_detection")

Hugging Face Download

We recommend downloading the model via the Hugging Face CLI or Hub SDK.

Guidance:Before downloading, install huggingface_hub with:

Guidance
pip install -U huggingface_hub

CLI Download

Download the full repository

Download the full repository
huggingface-cli download dima806/fairface_age_image_detection

Download a single file to a local folder (e.g. config.json into ./dir)

Download a single file to a local folder (e.g. config.json into ./dir)
huggingface-cli download dima806/fairface_age_image_detection config.json --local-dir ./dir

See the official docs for more CLI options

SDK Download

SDK Download
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('dima806/fairface_age_image_detection')

Git Download

Make sure git-lfs is installed first

Git Download
git lfs install
git clone https://huggingface.co/dima806/fairface_age_image_detection

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/dima806/fairface_age_image_detection

Model files are hosted on the Hugging Face Hub — download directly via HF CLI / SDK / Git, not through this site.

PyTorch / Transformers Usage

Install Transformers

Install Transformers
pip install -U transformers torch

Load the model and run inference

Load the model and run inference
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('dima806/fairface_age_image_detection')
tokenizer = AutoTokenizer.from_pretrained('dima806/fairface_age_image_detection')

Model Download

We recommend downloading the model via the ModelScope CLI or SDK.

Guidance:Before downloading, install ModelScope with:

Guidance
pip install modelscope

CLI Download

Download the full repository

Download the full repository
modelscope download --model dima806/fairface_age_image_detection

Download a single file to a local folder (e.g. README.md into ./dir)

Download a single file to a local folder (e.g. README.md into ./dir)
modelscope download --model dima806/fairface_age_image_detection README.md --local_dir ./dir

See the docs for more CLI options

SDK Download

SDK Download
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('dima806/fairface_age_image_detection')

Git Download

Make sure git-lfs is installed first

Git Download
git lfs install
git clone https://www.modelscope.cn/dima806/fairface_age_image_detection.git

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/dima806/fairface_age_image_detection.git

ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。

Notebook Quickstart

Install the ModelScope library

Install the ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

Load the model and run inference

Load the model and run inference
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

p = pipeline('text-generation', 'dima806/fairface_age_image_detection')

Full Documentation

来源: HuggingFace

---
license: apache-2.0
metrics:

  • accuracy

  • f1

base_model:
  • google/vit-base-patch16-224-in21k

pipeline_tag: image-classification
library_name: transformers
datasets:
  • nateraw/fairface

---
Detects age group with about 59% accuracy based on an image.

See https://www.kaggle.com/code/dima806/age-group-image-classification-vit for details.

!image/png

code
Classification report:

precision recall f1-score support

0-2 0.7803 0.7500 0.7649 180
3-9 0.7998 0.7998 0.7998 1249
10-19 0.5361 0.4236 0.4733 1086
20-29 0.6402 0.7221 0.6787 3026
30-39 0.4935 0.5083 0.5008 2099
40-49 0.4848 0.4386 0.4606 1238
50-59 0.5000 0.4814 0.4905 725
60-69 0.4497 0.4685 0.4589 286
more than 70 0.6897 0.1802 0.2857 111

accuracy 0.5892 10000
macro avg 0.5971 0.5303 0.5459 10000
weighted avg 0.5863 0.5892 0.5844 10000

Join our Telegram