---
title: cv_retinafce_recognition
canonical_url: "https://www.modelscope.cn/models/bubbliiiing/cv_retinafce_recognition"
md_url: "https://www.modelscope.cn/models/bubbliiiing/cv_retinafce_recognition.md"
repository: bubbliiiing/cv_retinafce_recognition
chinese_name: "Retinaface+CurricularFace人脸识别模型"
last_updated: 2023-09-15
license: "Apache License 2.0"
pipeline_tag: face-recognition
tasks:
  - face-recognition
library_name:
  - pytorch
frameworks:
  - pytorch
domain:
  - cv
downloads: 6541575
stars: 69
tags:
  - TFace
---

# cv_retinafce_recognition

> cv_retinafce_recognition - bubbliiiing 在 ModelScope 开源的模型。Retinaface+CurricularFace人脸识别模型，解除mmcv依赖。

bubbliiiing/cv_retinafce_recognition 是 ModelScope 魔搭社区上的face-recognition模型，采用 Apache License 2.0 许可。

- **Repository**: bubbliiiing/cv_retinafce_recognition
- **License**: Apache License 2.0
- **Tasks**: face-recognition
- **Tags**: TFace
- **Downloads**: 6541575
- **Stars**: 69
- **Last updated**: 2023-09-15

Source: https://www.modelscope.cn/models/bubbliiiing/cv_retinafce_recognition

---

# CurricularFace + Retinaface 模型介绍

## 模型描述
CurricularFace为目前人脸识别的SOTA方法之一，其主要思想是采用课程学习的思想动态关注训练数据中的难例样本。此前的方法在训练中对于错分类的样本，要么未充分挖掘难例导致性能问题，要么在训练初期关注难例导致收敛问题。基于此，CurricularFace提出Adaptive Curriculum Learning Loss, 在训练过程中动态调整easy和hard样本的重要性，使训练初期关注简单样本，训练后期关注难例样本，而对难易样本分配不同重要性是通过设计一个代表收敛进度的指示函数来自适应调整的。论文已发表至CVPR-2020（[论文地址](https://arxiv.org/abs/2004.00288), [代码地址](https://github.com/Tencent/TFace/tree/master/recognition)）。

RetinaFace为当前学术界和工业界精度较高的人脸检测和人脸关键点定位二合一的方法，被CVPR 2020 录取([论文地址](https://arxiv.org/abs/1905.00641), [代码地址](https://github.com/biubug6/Pytorch_Retinaface)))，该方法的主要贡献是:
- 引入关键点分支，可以在训练阶段引入关键点预测分支进行多任务学习，提供额外的互补特征，inference去掉关键点分支即可，并不会引入额外的计算量。

## 使用方式和范围

使用方式：
- 推理：输入经过对齐的人脸图片(112x112)，返回人脸特征向量(512维)，为便于体验，集成了人脸检测和关键点模型[Retinaface](https://www.modelscope.cn/models/damo/cv_resnet50_face-detection_retinaface/summary)，输入两张图片，各自进行人脸检测选择最大脸并对齐后提取特征，然后返回相似度比分

目标场景:
- 人脸识别应用广泛，如考勤，通行，人身核验，智慧安防等场景

#### 代码范例
```python
import cv2
import numpy as np
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

inference = pipeline("face_recognition", model='bubbliiiing/cv_retinafce_recognition', model_revision='v1.0.3')

img1 = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/face_recognition_1.png'
img2 = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/face_recognition_2.png'
emb1 = inference(dict(user=img1))[OutputKeys.IMG_EMBEDDING]
emb2 = inference(dict(user=img2))[OutputKeys.IMG_EMBEDDING]
sim = np.dot(emb1[0], emb2[0])
print(f'Face cosine similarity={sim:.3f}, img1:{img1}  img2:{img2}')
```

## 模型性能指标
暂无

## 来源说明
本模型及代码来自开源社区([地址](https://github.com/Tencent/TFace/tree/master/recognition))，请遵守相关许可。
