前期的文章我们分享了人脸的识别以及如何进行人脸数据的训练,本期文章我们结合人脸识别的
模型进行人脸年龄的检测
人脸年龄的检测步骤
1、首先需要进行人脸的检测
2、把检测到的人脸数据给年龄检测模型去检测
3、把检测结果呈现到图片上
人脸年龄检测
import numpy as np
import cv2import osAGE_LIST = ["(0-2)", "(4-6)", "(8-12)", "(15-20)", "(25-32)",
"(38-43)", "(48-53)", "(60-100)"]
prototxtFacePath = "model/deploy.prototxt"
weightsFacePath = "model/res10_300x300_ssd_iter_140000.caffemodel"
faceNet = cv2.dnn.readNet(prototxtFacePath, weightsFacePath)prototxtAgePath = "model/age_deploy.prototxt"
weightsAgePath = "model/age_net.caffemodel"
ageNet = cv2.dnn.readNet(prototxtAgePath, weightsAgePath)
初始化模型年龄段,由于模型是按照年龄段来进行训练的,