日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Python基于Dlib的人臉識(shí)別系統(tǒng)的實(shí)現(xiàn)

瀏覽:32日期:2022-08-06 08:52:16

之前已經(jīng)介紹過人臉識(shí)別的基礎(chǔ)概念,以及基于opencv的實(shí)現(xiàn)方式,今天,我們使用dlib來提取128維的人臉嵌入,并使用k臨近值方法來實(shí)現(xiàn)人臉識(shí)別。

人臉識(shí)別系統(tǒng)的實(shí)現(xiàn)流程與之前是一樣的,只是這里我們借助了dlib和face_recognition這兩個(gè)庫(kù)來實(shí)現(xiàn)。face_recognition是對(duì)dlib庫(kù)的包裝,使對(duì)dlib的使用更方便。所以首先要安裝這2個(gè)庫(kù)。

pip3 install dlibpip3 install face_recognition

然后,還要安裝imutils庫(kù)

pip3 install imutils

我們看一下項(xiàng)目的目錄結(jié)構(gòu):

.├── dataset│ ├── alan_grant [22 entries exceeds filelimit, not opening dir]│ ├── claire_dearing [53 entries exceeds filelimit, not opening dir]│ ├── ellie_sattler [31 entries exceeds filelimit, not opening dir]│ ├── ian_malcolm [41 entries exceeds filelimit, not opening dir]│ ├── john_hammond [36 entries exceeds filelimit, not opening dir]│ └── owen_grady [35 entries exceeds filelimit, not opening dir]├── examples│ ├── example_01.png│ ├── example_02.png│ └── example_03.png├── output│ ├── lunch_scene_output.avi│ └── webcam_face_recognition_output.avi├── videos│ └── lunch_scene.mp4├── encode_faces.py├── encodings.pickle├── recognize_faces_image.py├── recognize_faces_video_file.py├── recognize_faces_video.py└── search_bing_api.py 10 directories, 12 files

首先,提取128維的人臉嵌入:

命令如下:

python3 encode_faces.py --dataset dataset --encodings encodings.pickle -d hog

記住:如果你的電腦內(nèi)存不夠大,請(qǐng)使用hog模型進(jìn)行人臉檢測(cè),如果內(nèi)存夠大,可以使用cnn神經(jīng)網(wǎng)絡(luò)進(jìn)行人臉檢測(cè)。

看代碼:

# USAGE# python encode_faces.py --dataset dataset --encodings encodings.pickle # import the necessary packagesfrom imutils import pathsimport face_recognitionimport argparseimport pickleimport cv2import os # construct the argument parser and parse the argumentsap = argparse.ArgumentParser()ap.add_argument('-i', '--dataset', required=True,help='path to input directory of faces + images')ap.add_argument('-e', '--encodings', required=True,help='path to serialized db of facial encodings')ap.add_argument('-d', '--detection-method', type=str, default='hog',help='face detection model to use: either `hog` or `cnn`')args = vars(ap.parse_args()) # grab the paths to the input images in our datasetprint('[INFO] quantifying faces...')imagePaths = list(paths.list_images(args['dataset'])) # initialize the list of known encodings and known namesknownEncodings = []knownNames = [] # loop over the image pathsfor (i, imagePath) in enumerate(imagePaths):# extract the person name from the image pathprint('[INFO] processing image {}/{}'.format(i + 1,len(imagePaths)))name = imagePath.split(os.path.sep)[-2] # load the input image and convert it from RGB (OpenCV ordering)# to dlib ordering (RGB)image = cv2.imread(imagePath)rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # detect the (x, y)-coordinates of the bounding boxes# corresponding to each face in the input imageboxes = face_recognition.face_locations(rgb,model=args['detection_method']) # compute the facial embedding for the faceencodings = face_recognition.face_encodings(rgb, boxes) # loop over the encodingsfor encoding in encodings:# add each encoding + name to our set of known names and# encodingsknownEncodings.append(encoding)knownNames.append(name) # dump the facial encodings + names to diskprint('[INFO] serializing encodings...')data = {'encodings': knownEncodings, 'names': knownNames}f = open(args['encodings'], 'wb')f.write(pickle.dumps(data))f.close()

輸出結(jié)果是每張圖片輸出一個(gè)人臉的128維的向量和對(duì)于的名字,并序列化到硬盤,供后續(xù)人臉識(shí)別使用。

識(shí)別圖像中的人臉:

這里使用KNN方法實(shí)現(xiàn)最終的人臉識(shí)別,而不是使用SVM進(jìn)行訓(xùn)練。

命令如下:

python3 recognize_faces_image.py --encodings encodings.pickle --image examples/example_01.png

看代碼:

# USAGE# python recognize_faces_image.py --encodings encodings.pickle --image examples/example_01.png # import the necessary packagesimport face_recognitionimport argparseimport pickleimport cv2 # construct the argument parser and parse the argumentsap = argparse.ArgumentParser()ap.add_argument('-e', '--encodings', required=True,help='path to serialized db of facial encodings')ap.add_argument('-i', '--image', required=True,help='path to input image')ap.add_argument('-d', '--detection-method', type=str, default='cnn',help='face detection model to use: either `hog` or `cnn`')args = vars(ap.parse_args()) # load the known faces and embeddingsprint('[INFO] loading encodings...')data = pickle.loads(open(args['encodings'], 'rb').read()) # load the input image and convert it from BGR to RGBimage = cv2.imread(args['image'])rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # detect the (x, y)-coordinates of the bounding boxes corresponding# to each face in the input image, then compute the facial embeddings# for each faceprint('[INFO] recognizing faces...')boxes = face_recognition.face_locations(rgb,model=args['detection_method'])encodings = face_recognition.face_encodings(rgb, boxes) # initialize the list of names for each face detectednames = [] # loop over the facial embeddingsfor encoding in encodings:# attempt to match each face in the input image to our known# encodingsmatches = face_recognition.compare_faces(data['encodings'],encoding)name = 'Unknown' # check to see if we have found a matchif True in matches:# find the indexes of all matched faces then initialize a# dictionary to count the total number of times each face# was matchedmatchedIdxs = [i for (i, b) in enumerate(matches) if b]counts = {} # loop over the matched indexes and maintain a count for# each recognized face facefor i in matchedIdxs:name = data['names'][i]counts[name] = counts.get(name, 0) + 1 # determine the recognized face with the largest number of# votes (note: in the event of an unlikely tie Python will# select first entry in the dictionary)name = max(counts, key=counts.get)# update the list of namesnames.append(name) # loop over the recognized facesfor ((top, right, bottom, left), name) in zip(boxes, names):# draw the predicted face name on the imagecv2.rectangle(image, (left, top), (right, bottom), (0, 255, 0), 2)y = top - 15 if top - 15 > 15 else top + 15cv2.putText(image, name, (left, y), cv2.FONT_HERSHEY_SIMPLEX,0.75, (0, 255, 0), 2) # show the output imagecv2.imshow('Image', image)cv2.waitKey(0)

實(shí)際效果如下:

Python基于Dlib的人臉識(shí)別系統(tǒng)的實(shí)現(xiàn)

如果要詳細(xì)了解細(xì)節(jié),請(qǐng)參考:https://www.pyimagesearch.com/2018/06/18/face-recognition-with-opencv-python-and-deep-learning/

到此這篇關(guān)于Python基于Dlib的人臉識(shí)別系統(tǒng)的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Python Dlib人臉識(shí)別內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Python 編程
相關(guān)文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
欧美日韩第一| 黄色日韩在线| 国产欧美日韩视频在线| 日本中文字幕一区二区| 欧美一区91| 欧美国产极品| 另类专区亚洲| 欧美不卡高清一区二区三区| 99视频精品全部免费在线视频| 欧美粗暴jizz性欧美20| 亚洲欧美久久久| 日本不卡在线视频| 国产欧美日韩一区二区三区四区| 国产极品嫩模在线观看91精品| 狠狠久久伊人| 蜜桃国内精品久久久久软件9| 男女性色大片免费观看一区二区| 欧美另类中文字幕| 精品一区二区三区中文字幕在线| 日韩久久精品网| 亚洲专区一区| 69精品国产久热在线观看| 国产精品2区| 日韩免费视频| 99在线观看免费视频精品观看| 中文字幕一区二区三区在线视频| 奇米777国产一区国产二区| 久久久国产精品入口麻豆| 欧美日韩在线观看视频小说| 亚洲色图国产| 久久精品一区二区国产| 久久久噜噜噜| 免费不卡在线观看| 久久中文字幕一区二区三区| 欧美日韩在线播放视频| 日本不卡视频一二三区| 国产精品不卡| 午夜欧美精品久久久久久久| 亚洲精品综合| 国产成人免费| 免费人成精品欧美精品| 国产极品嫩模在线观看91精品| 99tv成人| 久久国产视频网| 99国产精品免费视频观看| 日韩中文字幕视频网| 丰满少妇一区| 中文字幕一区二区三区四区久久 | 男女激情视频一区| 久久精品一区二区国产| 国产亚洲在线观看| 国产精品a级| 亚洲免费成人| 麻豆一区二区三| 水蜜桃久久夜色精品一区的特点| 久久av资源| 香蕉精品999视频一区二区| 久久精品国内一区二区三区| 天堂av在线一区| 国产精品亚洲一区二区三区在线观看| 日韩精品免费视频人成| 欧美+亚洲+精品+三区| 麻豆精品视频在线观看| 免播放器亚洲| 日韩不卡免费高清视频| 国产精品三级| 亚洲欧美久久| 成人日韩在线观看| 欧美激情 亚洲a∨综合| 亚洲色图国产| 蜜桃视频欧美| 天堂√中文最新版在线| 91成人小视频| 丝袜诱惑制服诱惑色一区在线观看 | 免费在线欧美黄色| 久久成人一区| 久久三级视频| 国模大尺度视频一区二区| 亚洲欧洲日韩| 99riav1国产精品视频| 麻豆视频在线看| 国产欧美啪啪| 少妇精品在线| 国产手机视频一区二区 | 中文在线资源| 欧美国产另类| 日韩黄色在线观看| 视频一区视频二区中文| 欧美国产91| 国产资源在线观看入口av| 国产精品入口久久| 日韩一二三区在线观看| 日韩一区精品字幕| 欧美日韩国产高清| 久久精品国产大片免费观看| 成人一区而且| 久久精品国产亚洲aⅴ| 欧美日韩中文| 91嫩草精品| 亚洲精品第一| 综合激情视频| 免播放器亚洲一区| 久久成人一区| 久久av在线| 亚洲一区日韩在线| 中文国产一区| 99在线精品免费视频九九视| 99精品视频在线观看免费播放| 一区二区精品伦理...| 精品72久久久久中文字幕| 久久精品国产网站| 久草精品视频| 国产一区二区色噜噜| 国产一区二区三区黄网站| 久久中文欧美| 国产成人a视频高清在线观看| 日韩在线网址| 久久国际精品| 国产精品欧美三级在线观看| 欧美日韩精品一区二区三区在线观看| 亚洲ww精品| 欧美视频二区| 国产精品宾馆| 精品久久久久久久| 国产自产自拍视频在线观看| а√天堂8资源中文在线| 国产中文在线播放| 99精品综合| 亚洲神马久久| 婷婷视频一区二区三区| 国产毛片精品| 成人亚洲精品| 婷婷成人在线| 老色鬼久久亚洲一区二区| 亚洲精选成人| 日韩精品欧美精品| 欧美国产三级| 国产suv精品一区二区四区视频 | 麻豆免费精品视频| 日韩1区2区| 亚洲二区在线| 日韩在线卡一卡二| 欧美一级全黄| 精品久久久中文字幕| 精品三级久久| 国产一级一区二区| 亚洲精品伊人| 国产日本精品| 成人三级高清视频在线看| 99精品视频在线| 免费观看久久久4p| 国产精选一区| 在线精品亚洲欧美日韩国产| 久久中文视频| 视频一区日韩精品| 久久精品国产久精国产爱| 丝袜av一区| 亚洲人成亚洲精品| 精品久久免费| 黑丝一区二区三区| 日本午夜精品| 女生影院久久| 日韩精品一区第一页| 国产精品啊啊啊| 亚洲福利久久| 欧美日本一区| 久久精品中文| 日韩av不卡在线观看| 手机在线电影一区| 蜜臀av亚洲一区中文字幕| 国产精品1区| 久久麻豆精品| 91精品国产自产在线丝袜啪| 日韩高清成人| 日本欧美一区二区| 天堂√8在线中文| 人人爽香蕉精品| 成人一二三区| 午夜久久av| 99久久99久久精品国产片果冰| 日本精品一区二区三区在线观看视频| 中文字幕在线看片| 日本成人在线不卡视频| 欧洲精品一区二区三区| 日本精品另类| 欧美影院三区| 国产精品亲子伦av一区二区三区 | 国产亚洲永久域名| 久久99视频| 日韩中文字幕一区二区三区| 91视频一区| 97久久亚洲| 好吊视频一区二区三区四区| 久久99国产精品视频| 蜜臀av性久久久久蜜臀aⅴ流畅| 樱桃视频成人在线观看| 奇米色欧美一区二区三区| 亚洲午夜av| 久久久久久婷| 国产精品一国产精品k频道56|