InsightFace 高效地实现了各种人脸识别、人脸检测和人脸对齐算法,这些算法针对训练和部署进行了优化。
insightface 使用 onnxruntime 作为推理后端。 手动安装 onnxruntime-gpu
使用 GPU ,或者安装 onnxruntime
使用cpu
样例
import cv2
import numpy as np
import insightface
from insightface.app import FaceAnalysis
from insightface.data import get_image as ins_get_image
app = FaceAnalysis(providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
app.prepare(ctx_id=0, det_size=(640, 640))
img = ins_get_image('t1')
faces = app.get(img)
rimg = app.draw_on(img, faces)
cv2.imwrite("./t1_output.jpg", rimg)
代码将从 t1.jpg 图像中检测人脸,并在其上绘制检测结果。
模型
默认模型是buffalo_l, auto列表示是否自动下载,手动下载的,放到 ~/.insightface/models/ 下
Name | Detection Model | Recognition Model | Alignment | Attributes | Model-Size | Link | Auto |
---|---|---|---|---|---|---|---|
antelopev2 | SCRFD-10GF | ResNet100@Glint360K | 2d106 & 3d68 | Gender&Age | 407MB | link | N |
buffalo_l | SCRFD-10GF | ResNet50@WebFace600K | 2d106 & 3d68 | Gender&Age | 326MB | link | Y |
buffalo_m | SCRFD-2.5GF | ResNet50@WebFace600K | 2d106 & 3d68 | Gender&Age | 313MB | link | N |
buffalo_s | SCRFD-500MF | MBF@WebFace600K | 2d106 & 3d68 | Gender&Age | 159MB | link | N |
buffalo_sc | SCRFD-500MF | MBF@WebFace600K | - | - | 16MB | link | N |
识别准确率
Name | MR-ALL | 非洲 | 白人 | 南亚 | 东亚 | LFW | CFP-FP | AgeDB-30 | IJB-C(E4) |
---|---|---|---|---|---|---|---|---|---|
buffalo_l | 91.25 | 90.29 | 94.70 | 93.16 | 74.96 | 99.83 | 99.33 | 98.23 | 97.25 |
buffalo_s | 71.87 | 69.45 | 80.45 | 73.39 | 51.03 | 99.70 | 98.00 | 96.58 | 95.02 |
调用检测模型
import cv2
import numpy as np
import insightface
from insightface.app import FaceAnalysis
from insightface.data import get_image as ins_get_image
# Method-1, use FaceAnalysis
app = FaceAnalysis(allowed_modules=['detection']) # enable detection model only
app.prepare(ctx_id=0, det_size=(640, 640))
# Method-2, load model directly
detector = insightface.model_zoo.get_model('your_detection_model.onnx')
detector.prepare(ctx_id=0, input_size=(640, 640))
调用识别模型
import cv2
import numpy as np
import insightface
from insightface.app import FaceAnalysis
from insightface.data import get_image as ins_get_image
handler = insightface.model_zoo.get_model('your_recognition_model.onnx')
handler.prepare(ctx_id=0)
参考:
GitHub - deepinsight/insightface: State-of-the-art 2D and 3D Face Analysis Project
基于insightface实现的人脸识别和人脸注册_夜雨飘零1的博客-CSDN博客
https://www.cnblogs.com/divenswu/p/16450243.html文章来源:https://www.toymoban.com/news/detail-650615.html
https://github.com/deepinsight/insightface/tree/0cb03d391bb9335821448ce6e0519dbc870ec68d/examples文章来源地址https://www.toymoban.com/news/detail-650615.html
到了这里,关于insightface使用笔记的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!