face image quality assessment ediffiqa

提供商opencv
分类image-quality-assessment
许可证Apache-2.0
下载量0
星标0

简介

EdiffIQA 是一款由 OpenCV 提供的轻量级人脸图像质量评估模型。它主要解决的是在人脸识别、美颜或身份验证等实际业务场景中,如何快速筛选出“可用”照片的问题。该模型能客观量化人脸图像的清晰度、光照和质量得分,帮助开发者在预处理阶段剔除模糊或低质图片,从而显著提升后续识别算法的准确率。对于习惯使用 OpenCV 的开发者来说,其集成难度极低,可直接作为图像流水线中的质量把关环节。

核心亮点

  • 快速量化人脸图像质量,有效过滤模糊低质照片
  • 适配人脸识别预处理,提升后端算法识别率
  • 基于 OpenCV 生态,集成简单且部署成本极低
  • 采用 Apache-2.0 协议,支持商业化灵活部署

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("opencv/face_image_quality_assessment_ediffiqa")
tokenizer = AutoTokenizer.from_pretrained("opencv/face_image_quality_assessment_ediffiqa")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download opencv/face_image_quality_assessment_ediffiqa

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download opencv/face_image_quality_assessment_ediffiqa config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('opencv/face_image_quality_assessment_ediffiqa')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/opencv/face_image_quality_assessment_ediffiqa

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/opencv/face_image_quality_assessment_ediffiqa

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('opencv/face_image_quality_assessment_ediffiqa')
tokenizer = AutoTokenizer.from_pretrained('opencv/face_image_quality_assessment_ediffiqa')

完整文档

来源: HuggingFace

eDifFIQA(T)

eDifFIQA(T) is a light-weight version of the models presented in the paper eDifFIQA: Towards Efficient Face Image Quality Assessment based on Denoising Diffusion Probabilistic Models, it achieves state-of-the-art results in the field of face image quality assessment.

Notes:

  • The original implementation can be found here.
  • The included model combines a pretrained MobileFaceNet backbone, with a quality regression head trained using the proceedure presented in the original paper.
  • The model predicts quality scores of aligned face samples, where a higher predicted score corresponds to a higher quality of the input sample.
  • In the figure below we show the quality distribution on two distinct datasets: LFW[[1]](#1) and XQLFW[[2]](#2). The LFW dataset contains images of relatively high quality, whereas the XQLFW dataset contains images of variable quality. There is a clear difference between the two distributions, with high quality images from the LFW dataset receiving quality scores higher than 0.5, while the mixed images from XQLFW receive much lower quality scores on average.

!qualityDist

<a id="1">[1]</a>
B. Huang, M. Ramesh, T. Berg, and E. Learned-Miller
“Labeled Faces in the Wild: A Database for Studying Face Recognition in Unconstrained Environments”
University of Massachusetts, Amherst, Tech. Rep. 07-49,
October 2007.

<a id="2">[2]</a>
M. Knoche, S. Hormann, and G. Rigoll
“Cross-Quality LFW: A Database for Analyzing Cross-Resolution Image Face Recognition in Unconstrained Environments,” in Proceedings of the IEEE International Conference on Automatic Face and Gesture Recognition (FG), 2021, pp. 1–5.

Demo

*NOTE*: The provided demo uses ../face_detection_yunet for face detection, in order to properly align the face samples, while the original implementation uses a RetinaFace(ResNet50) model, which might cause some differences between the results of the two implementations.

To try the demo run the following commands:

shell
# Assess the quality of 'image1'
python demo.py -i /path/to/image1

Output all the arguments of the demo

python demo.py --help

Example outputs

!ediffiqaDemo

The demo outputs the quality of the sample via terminal (print) and via image in __results.jpg__.

License

All files in this directory are licensed under CC-BY-4.0.