InsightFace
- deepinsight/insightfaceGitHubdeepinsight/insightfacedeepinsight/insightface · 2D / 3D 人脸分析综合开源生态,涵盖人脸检测(RetinaFace / SCRFD)、识别(ArcFace / Partial FC)、关键点对齐(2d106 / 3d68)、属性预测、可选 RGB 活体检测、视频打码(PrivateFrame)与人物/人体综合分析(PersonAnalysis)。笔记:InsightFace
- 2D / 3D 人脸分析综合开源生态,涵盖人脸检测(RetinaFace / SCRFD)、识别(ArcFace / Partial FC)、关键点对齐(2d106 / 3d68)、属性预测、可选 RGB 活体检测、视频打码(PrivateFrame)与人物/人体综合分析(PersonAnalysis)。
- Python 推理包基于 ONNX Runtime,支持自动选择
CoreMLExecutionProvider -> CUDAExecutionProvider -> CPUExecutionProvider。
License
- 库代码:MIT License(允许学术与商业使用)。
- 官方预训练模型权重(Model Zoo):全部仅限非商用研究用途(non-commercial research purposes only),无论自动下载还是手动下载。
- 商业使用需要接入自有合规训练模型或向官方获取商业授权模型包。
安装
需要 Python 3.10+:
# 基础推理(FaceAnalysis / PersonAnalysis / ModelZoo,默认安装 CPU onnxruntime)
pip install -U insightface
# 视频人脸脱敏工具(额外安装 PyAV / PyYAML)
pip install -U "insightface[privateframe]"
# 桌面 Evaluation Studio GUI(Qt)
pip install -U "insightface[gui]"使用 NVIDIA CUDA 时,卸载 CPU 版 onnxruntime 并改装 onnxruntime-gpu(不要同时保留两个包):
pip uninstall -y onnxruntime
pip install onnxruntime-gpu快速示例
import cv2
from insightface.app import FaceAnalysis
# 默认加载 buffalo_l,首次运行自动下载至 ~/.insightface/models/
app = FaceAnalysis(name="buffalo_l")
app.prepare(ctx_id=0, det_size=(640, 640))
img = cv2.imread("input.jpg")
faces = app.get(img)
for f in faces:
# bbox, kps(5点), det_score, normed_embedding(512-d L2归一化向量), gender, age
print(f.bbox, f.det_score, f.normed_embedding.shape)开启可选 RGB 活体检测 addon(自动下载 ~/.insightface/addons/liveness.onnx):
app = FaceAnalysis(addons=["liveness"])
app.prepare()
faces = app.get(img)
for f in faces:
print(f.liveness.status, f.liveness.is_live, f.liveness.live_score)Model Zoo 常用模型包
模型包默认存放在 <root>/models/<name>/(默认 <root> 为 ~/.insightface),离线环境可从 model-zoo releaseGitHubdeepinsight/insightface/releases/tag/model-zoo 手动下载解压。
经典 FaceAnalysis 模型包
| 模型包 | 检测模型 | 识别模型 | 对齐关键点 | 属性 | 体积 | 定位 |
|---|---|---|---|---|---|---|
buffalo_l | SCRFD-10GF | ResNet50@WebFace600K | 2d106 & 3d68 | Gender & Age | 326 MB | 通用高精度默认包 |
buffalo_m | SCRFD-2.5GF | ResNet50@WebFace600K | 2d106 & 3d68 | Gender & Age | 313 MB | 识别精度同 buffalo_l,检测更轻 |
buffalo_s | SCRFD-500MF | MobileFaceNet@WebFace600K | 2d106 & 3d68 | Gender & Age | 159 MB | 轻量全功能 |
buffalo_sc | SCRFD-500MF | MobileFaceNet@WebFace600K | - | - | 16 MB | 极简检测+识别(无关键点与属性),适合边缘/CPU |
antelopev2 | SCRFD-10GF | ResNet100@Glint360K | 2d106 & 3d68 | Gender & Age | 407 MB | 更大骨干,InstantID 等下游生态常用 |
注:官方报告
buffalo_l在 LFW 99.83 / IJB-C(E4) 97.25 / MR-ALL 91.25;buffalo_s为 LFW 99.70 / IJB-C(E4) 95.02 / MR-ALL 71.87(数据来源:官方 Model Zoo 文档)。
InsightFace 2.x 新模型包
InsightFace 2.0/2.1 引入带 manifest.json(含预处理参数与 SHA-256 校验)的 V2 任务感知模型包:
| 模型包 | 适用接口 / 场景 | 说明 |
|---|---|---|
raccoon_s / raccoon_l | FaceAnalysis / PrivateFrame | V2 manifest 格式,PrivateFrame 默认使用 raccoon_s |
cheetah_s / cheetah_l | PersonAnalysis / GUI | 组合人体检测 + 人体 ReID + 人脸检测 + 人脸识别(人脸模型分别复用 buffalo_s / buffalo_l) |
工程常见注意点
- 只加载需要的模块:如果只需要检测和识别向量,构造时传
allowed_modules=['detection', 'recognition'],可跳过 2d106/3d68/genderage 推理,大幅提速。 - 特征比对:直接使用
face.normed_embedding做点积即余弦相似度(范围[-1, 1]);跨模型包(如buffalo_l与antelopev2、buffalo_s)的向量不兼容,切换识别模型后必须重建向量库。 - 检测尺寸
det_size:小人脸或合影场景可调大(如(640, 640)或(1024, 1024));高分辨率输入下过小的det_size会漏检远景人脸。
参考
- InsightFace GitHubGitHubdeepinsight/insightfacedeepinsight/insightface · 2D / 3D 人脸分析综合开源生态,涵盖人脸检测(RetinaFace / SCRFD)、识别(ArcFace / Partial FC)、关键点对齐(2d106 / 3d68)、属性预测、可选 RGB 活体检测、视频打码(PrivateFrame)与人物/人体综合分析(PersonAnalysis)。笔记:InsightFace
- InsightFace Python Package READMEGitHub 文件deepinsight/insightface/python-package/README.md
- InsightFace Model ZooGitHub 文件deepinsight/insightface/model_zoo/README.md
- InsightFace Python Model Zoo GuideGitHub 文件deepinsight/insightface/python-package/docs/model_zoo.md
关联信息
反向链接、本文链接的其他页面和外部资料。
反向链接
- Face Awesome笔记 · InsightFace
人脸检测、对齐、识别、活体、修复与身份保持生成开源项目及模型索引。 · deepinsight/insightface · Python / ONNX Runtime 人脸分析生态(RetinaFace、SCRFD、ArcFace、2d106/3d68、Liveness、PersonAnalysis);Python 库代码为 MIT,官方预训练模型权重...
- Face Glossary笔记 · InsightFace
Face Models · Face Awesome · InsightFace · | abbr. | stand for | means | desc | · | FR | Face Recognition | 人脸识别 | 广义指检测、对齐、特征提取与比对;狭义指提取特征并判定身份 |
- Face Models笔记 · InsightFace
人脸分析、识别、活体检测、修复与生成模型索引。 · Face Awesome - 按任务分类的开源项目、模型与基准索引 · Face Glossary - 人脸检测、对齐、识别、活体与评测术语速查 · InsightFace - RetinaFace / SCRFD / ArcFace 与 ONNX Model Zoo 速查
参考资料
GitHub5 条
- deepinsight/insightfacegithub.com/deepinsight/insightface
- deepinsight/insightface/model_zoo/README.mdgithub.com/deepinsight/insightface/blob/master/model_zoo/README.md
- deepinsight/insightface/python-package/docs/model_zoo.mdgithub.com/deepinsight/insightface/blob/master/python-package/docs/model_zoo.md
- deepinsight/insightface/python-package/README.mdgithub.com/deepinsight/insightface/blob/master/python-package/README.md
- deepinsight/insightface/releases/tag/model-zoogithub.com/deepinsight/insightface/releases/tag/model-zoo