opencv深度学习人工智能技术打假抖音“伪娘“之性别实时检测

抖音的美颜功能强大到能把男人变成伪娘,甚至还有年轻小伙刷礼物,疯狂追求,殊不知,你追求的大美女在生活中却是一个油腻大叔。本期文章带你如何使用人工智能技术打假抖音伪娘

人脸年龄的检测步骤

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, startY, endX, endY) = box.astype("int")			face = frame[startY:endY, startX:endX]
			if face.shape[0] < 20 or face.shape[1] < 20:
				continue
			faceBlob = cv2.dnn.blobFromI

你可能感兴趣的:(人工智能之计算机视觉,人工智能,opencv,深度学习)