抖音的美颜功能强大到能把男人变成伪娘,甚至还有年轻小伙刷礼物,疯狂追求,殊不知,你追求的大美女在生活中却是一个油腻大叔。本期文章带你如何使用人工智能技术打假抖音伪娘
人脸年龄的检测步骤
0、打开摄像头,获取图片数据
1、对图片进行人脸的检测,需要人脸检测模型
2、把检测到的人脸数据给性别检测模型去检测,需要性别检测模型
3、把检测结果实时呈现到图片上
import numpy as np
import timeimport cv2import osdef predict_gender(frame, faceNet, ageNet): genderList = ['Male', 'Female']
results = []
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(frame, 1.0, (300, 300), (104.0, 177.0, 123.0)) faceNet.setInput(blob) detections = faceNet.forward() for i in range(0, detections.shape[2]):
confidence = detections[0, 0, i, 2]
if confidence > 0.5: box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
(startX,