面部识别算法是如何工作的?

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"过去十年,深度学习领域出现了许多先进的新算法和突破性的研究,并且引入了新的计算机视觉算法。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"这一切始于2012年的AlexNet。AlexNet是一个深度(卷积)神经网络,它在ImageNet数据集(拥有超过1400万张图片的数据集)上取得了很高的准确率。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"人类是如何识别人脸的?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"也许,人类大脑中的神经元首先识别场景中的人脸(从人的体形和背景),然后提取面部特征,并通过这些特征对人进行分类。我们已经在一个无限大的数据集和"},{"type":"link","attrs":{"href":"https:\/\/www.engati.com\/glossary\/neural-networks","title":null,"type":null},"content":[{"type":"text","text":"神经网络"}]},{"type":"text","text":"上进行了训练。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"机器中的"},{"type":"link","attrs":{"href":"https:\/\/www.engati.com\/glossary\/facial-recognition","title":null,"type":null},"content":[{"type":"text","text":"面部识别"}]},{"type":"text","text":"是以同样的方式实现的。首先,我们采用面部检测算法来检测场景中的人脸,然后从检测到的人脸中提取面部特征,最后使用算法对人进行分类。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/39\/11\/3983b31c3e2edf64f66352186d8b9311.png","alt":null,"title":"面部识别系统的工作流","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"1. 人脸检测"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"人脸检测是物体检测的一个特化版本,特别之处在于,它只检测一种物体,即人脸。就像计算机科学里需要权衡时间和空间,机器学习算法也需要在推理速度和准确性之间进行权衡。现在有很多物体检测算法,不同算法对速度和准确性的取舍有所不同。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"本文评估了如下几个最先进的物体检测算法:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"OpenCV(Haar-Cascade)"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"MTCNN"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"YoloV3和Yolo-Tiny"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"SSD"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"BlazeFace"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ShuffleNet和Faceboxes"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"为了构建一个强大的人脸检测系统,我们需要准确且快速的算法,以满足在GPU以及移动设备上实时运行的需要。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"准确度"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在流媒体视频的实时推理中,人们的面部可能有不同的姿势、遮挡和照明效果。因此,算法能在不同的光照条件和不同姿态下精确检测人脸非常重要。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":""}]},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/ac\/5b\/ac93bc1bc84bacda8b1426402e91d35b.png","alt":null,"title":"在不同的姿态和光照条件下的人脸检测","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"OpenCV(Haar-ascade)"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我们从OpenCV的Haar-cascade实现开始,它是一个用C语言编写的开源图像处理库。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"优点:"},{"type":"text","text":"由于这个库是用C语言编写的,所以它在实时系统中的推理速度非常快。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"缺点:"},{"type":"text","text":"这个实现的问题是它无法检测侧脸,而且在不同姿态和光照条件下表现欠佳。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"MTCNN"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"这种算法基于深度学习方法。它使用深度级联卷积神经网络(Deep Cascaded Convolutional Neural Networks)来检测人脸。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"优点:"},{"type":"text","text":"它比OpenCV的Haar-Cascade方法准确性更高"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"缺点:"},{"type":"text","text":"运行时间较长。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"YOLOV3"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"YOLO(“You only  look  once”)是用于物体检测的最先进的深度学习算法。它由许多卷积神经网络组成,形成一个深度CNN模型(深度意味着模型架构复杂性很高)。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"原始的YOLO模型可以检测80个不同的物体类别,而且检测精度很高,而我们只需要用该模型检测一个物体——人脸。我们在WiderFace(包含"},{"type":"text","marks":[{"type":"strong"}],"text":"393,703个面部标签"},{"type":"text","text":"的图像数据集)数据集上训练了这个算法。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"YOLO算法还有一个微型版本,即Yolo-Tiny。Yolo-Tiny需要的计算时间比较少,但却牺牲了一些准确性。我们用相同的数据集训练了一个Yolo-Tiny模型,其边界框(boundary box)结果并不一致。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"优点:"},{"type":"text","text":"非常准确,没有任何缺陷。比MTCNN更快。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"缺点:"},{"type":"text","text":"由于具有巨大的深度神经网络层,它需要的计算资源更多。因此,该算法在CPU或移动设备上运行地很慢。在GPU上,它的大型架构也需要耗费更多的VRAM。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"SSD"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"SSD(Single Shot Detector)也是一个类似YOLO的深度卷积神经网络模型。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"优点:"},{"type":"text","text":"良好的准确性。它可以检测各种姿势、光照和遮挡。良好的推理速度。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"缺点:"},{"type":"text","text":"比YOLO模型差。虽然推理速度较好,但仍不能满足在CPU、低端GPU或移动设备上运行的要求。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"BlazeFace"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"就像它的名字一样,它是由谷歌发布的速度极快的人脸检测算法。它接受128x128维的图像输入,推理时间是亚毫秒级,已优化到可以在手机中使用。它速度这么快的原因是:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"YOLO和SSD用来检测大量的类别,而BlazeFace不同,是一个专门的人脸检测器模型。因此BlazeFace的深度卷积神经网络架构比YOLO和SSD的架构小。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"它采用的是深度可分离卷积层(Depthwise Separable Convolution),而不是标准的卷积层,这样就降低了计算量。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"优点:"},{"type":"text","text":"非常好的推理速度,且人脸检测的准确率高。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"缺点:"},{"type":"text","text":"这个模型的优化目标是对手机摄像头获取的图像进行人脸检测,因此它预期人脸会覆盖图像中的大部分区域,而当人脸尺寸较小时,它的识别效果就是很好。所以,当对闭路电视摄像机获取的(CCTV ,Closed Circuit Tele Vision)图像进行人脸检测时,它表现得并不理想。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Faceboxes"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Faceboxes是我们使用的最新的人脸检测算法。与BlazeFace类似,它是一个小型的深度卷积神经网络,只为检测一种类别——人脸而设计。它的推理时间可满足CPU上的实时检测需求。它的准确度可以与Yolo人脸检测算法相媲美,而且,不管图像中的人脸较大还是较小,它都可以精确地检测。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"优点:"},{"type":"text","text":"推理速度快,准确性好。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"缺点:"},{"type":"text","text":"评估仍在进行中。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"2.特征提取"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在检测到图像中的人脸后,我们对人脸进行裁剪,并将其送入特征提取算法,该算法创建面部嵌入(face-embeddings)——一个代表人脸特征的多维(主要是128或512维)向量。我们使用FaceNet算法来创建面部嵌入。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"嵌入向量代表一个人的面部特征。因此,同一个人的两个不同图像的嵌入向量之间的距离比较接近,而不同人的嵌入向量之间的距离比较远。其中,两个向量之间的距离采用的是欧氏距离。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"3. 面部分类"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在得到面部嵌入向量后,我们训练了一种"},{"type":"link","attrs":{"href":"https:\/\/www.engati.com\/glossary\/classification-algorithm","title":null,"type":null},"content":[{"type":"text","text":"分类算法"}]},{"type":"text","text":",即K-近邻(K-nearest neighbor,KNN)算法,根据一个人的嵌入向量对其进行分类。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"假设在一个组织中,有1000名员工。我们创建了所有员工的面部嵌入,并使用嵌入向量训练分类算法。该算法以面部嵌入向量作为输入,以人的名字作为输出返回。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在把图片放到网上前,用户可以采用过滤器修改图片中的特定像素。人眼无法察觉这些变化,但它会让面部识别算法觉得很困惑。 —— "},{"type":"link","attrs":{"href":"https:\/\/www.thalesgroup.com\/en\/markets\/digital-identity-and-security\/government\/biometrics\/facial-recognition","title":null,"type":null},"content":[{"type":"text","text":"ThalesGroup"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"当前,面部识别算法已经取得了巨大的进步。但这仅仅是技术革命的开始。可以想象一下,未来面部识别算法和聊天机器人技术的联合起来是多么强大。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"英文原文:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/www.pimonk.com\/post\/how-do-facial-recognition-systems-algorithms-work-in-2021","title":null,"type":null},"content":[{"type":"text","text":"https:\/\/www.pimonk.com\/post\/how-do-facial-recognition-systems-algorithms-work-in-2021"}]}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章