insightface 提取人脸特征(超简洁)

insightface 是一款优秀的开源人脸检测/识别库,下面将展示如何使用它

安装:

pip install insightface -i https://mirror.baidu.com/pypi/simple

如需使用GPU资源(可选):

pip install onnxruntime-gpu==1.3.0 -i https://mirror.baidu.com/pypi/simple

我的cuda是10.1的,请选择对应版本安装

示例:

import insightface
import cv2


model = insightface.app.FaceAnalysis()
model.prepare(ctx_id=0, det_thresh=0.45)

face_img = cv2.imread('test.jpg')
rgb_small_frame = face_img[:, :, ::-1]
res = model.get(rgb_small_frame)

print('人脸数量:', len(res))
print('res: ', res[0].keys())  # 结果包括 3d-points, 2d-points, age, gender, box, feature
原文地址:https://www.cnblogs.com/niulang/p/15792954.html