面部識別算法是如何工作的?

{"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"}]}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章