最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用python?AI快速比對(duì)兩張人臉圖像及遇到的坑

 更新時(shí)間:2023年02月24日 08:34:31   作者:Python?集中營(yíng)  
這篇文章主要介紹了如何使用python?AI快速比對(duì)兩張人臉圖像?實(shí)現(xiàn)過(guò)程比較簡(jiǎn)單,但是第三方python依賴的安裝過(guò)程較為曲折,下面是通過(guò)實(shí)踐對(duì)比總結(jié)出來(lái)的能夠支持的幾個(gè)版本,避免大家踩坑,需要的朋友可以參考下

本篇文章的代碼塊的實(shí)現(xiàn)主要是為了能夠快速的通過(guò)python第三方非標(biāo)準(zhǔn)庫(kù)對(duì)比出兩張人臉是否一樣。

實(shí)現(xiàn)過(guò)程比較簡(jiǎn)單,但是第三方python依賴的安裝過(guò)程較為曲折,下面是通過(guò)實(shí)踐對(duì)比總結(jié)出來(lái)的能夠支持的幾個(gè)版本,避免大家踩坑。

python版本:3.6.8
dlib版本:19.7.0
face-recognition版本:0.1.10

開(kāi)始之前,我們選擇使用pip的方式對(duì)第三方的非標(biāo)準(zhǔn)庫(kù)進(jìn)行安裝。

pip install cmake

pip install dlib==19.7.0

pip install face-recognition==0.1.10

pip install opencv-python

然后,將使用到的模塊cv2/face-recognition兩個(gè)模塊導(dǎo)入到代碼塊中即可。

# OpenCV is a library of programming functions mainly aimed at real-time computer vision.
import cv2

# It's loading a pre-trained model that can detect faces in images.
import face_recognition

新建一個(gè)python函數(shù)get_face_encodings,用來(lái)獲取人臉部分的編碼,后面可以根據(jù)這個(gè)編碼來(lái)進(jìn)行人臉比對(duì)。

def get_face_encodings(image_path):
    """
    It takes an image path, loads the image, finds the faces in the image, and returns the 128-d face encodings for each
    face

    :param image_path: The path to the image to be processed
    """
    # It's loading a pre-trained model that can detect faces in images.
    image = cv2.imread(image_path)

    # It's converting the image from BGR to RGB.
    image_RGB = image[:, :, ::-1]

    image_face = face_recognition.face_locations(image_RGB)

    # It's taking the image and the face locations and returning the face encodings.
    face_env = face_recognition.face_encodings(image_RGB, image_face)

    # It's returning the first face encoding in the list.
    return face_env[0]

上述函數(shù)中注釋都是通過(guò)Pycharm插件自動(dòng)生成的,接下來(lái)我們直接調(diào)用get_face_encodings函數(shù)分別獲取兩個(gè)人臉的編碼。

# It's taking the image and the face locations and returning the face encodings.
ima1 = get_face_encodings('03.jpg')

# It's taking the image and the face locations and returning the face encodings.
ima2 = get_face_encodings('05.jpg')

# It's taking the image and the face locations and returning the face encodings.
ima1 = get_face_encodings('03.jpg')

# It's taking the image and the face locations and returning the face encodings.
ima2 = get_face_encodings('05.jpg')

上面我們選擇了兩張附有人臉的圖片,并且已經(jīng)獲取到了對(duì)應(yīng)的人臉編碼。接著使用compare_faces函數(shù)進(jìn)行人臉比對(duì)。

# It's comparing the two face encodings and returning True if they match.
is_same = face_recognition.compare_faces([ima1], ima2, tolerance=0.3)[0]

print('人臉比對(duì)結(jié)果:{}'.format(is_same))

人臉比對(duì)結(jié)果:False

這個(gè)時(shí)候人臉比對(duì)結(jié)果已經(jīng)出來(lái)了,F(xiàn)alse代表不一樣。這里compare_faces有一個(gè)比較重要的參數(shù)就是tolerance=0.3,默認(rèn)情況下是0.6。

tolerance參數(shù)的值越小的時(shí)候代表比對(duì)要求更加嚴(yán)格,因此這個(gè)參數(shù)的大小需要根據(jù)實(shí)際情況設(shè)置,它會(huì)直接影響整個(gè)比對(duì)過(guò)程的結(jié)果。

到此這篇關(guān)于如何使用python AI快速比對(duì)兩張人臉圖像?的文章就介紹到這了,更多相關(guān)python AI快速比對(duì)兩張人臉圖像內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Python3.7中安裝openCV庫(kù)的方法

    Python3.7中安裝openCV庫(kù)的方法

    這篇文章主要介紹了Python3.7中安裝openCV庫(kù)的方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-07-07
  • Python如何為圖片添加水印

    Python如何為圖片添加水印

    這篇文章主要介紹了Python如何使用Python-Pillow庫(kù)給圖片添加水印的方法,非常的簡(jiǎn)單實(shí)用,有需要的小伙伴可以參考下
    2016-11-11
  • python 接口實(shí)現(xiàn) 供第三方調(diào)用的例子

    python 接口實(shí)現(xiàn) 供第三方調(diào)用的例子

    今天小編就為大家分享一篇python 接口實(shí)現(xiàn) 供第三方調(diào)用的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-08-08
  • Python機(jī)器學(xué)習(xí)之SVM支持向量機(jī)

    Python機(jī)器學(xué)習(xí)之SVM支持向量機(jī)

    這篇文章主要為大家詳細(xì)介紹了Python機(jī)器學(xué)習(xí)之SVM支持向量機(jī),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • python flask中靜態(tài)文件的管理方法

    python flask中靜態(tài)文件的管理方法

    下面小編就為大家分享一篇python flask中靜態(tài)文件的管理方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-03-03
  • 解決pygal.style的LightColorizedStyle參數(shù)問(wèn)題

    解決pygal.style的LightColorizedStyle參數(shù)問(wèn)題

    這篇文章主要介紹了解決pygal.style的LightColorizedStyle參數(shù)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • 深入解析Python中filter函數(shù)的使用

    深入解析Python中filter函數(shù)的使用

    在Python中,filter函數(shù)是一種內(nèi)置的高階函數(shù),它能夠接受一個(gè)函數(shù)和一個(gè)迭代器,然后返回一個(gè)新的迭代器,本文主要來(lái)介紹一下Python中filter函數(shù)的具體用法,需要的可以參考一下
    2023-07-07
  • 詳解Python連接MySQL數(shù)據(jù)庫(kù)的多種方式

    詳解Python連接MySQL數(shù)據(jù)庫(kù)的多種方式

    這篇文章主要介紹了Python連接MySQL數(shù)據(jù)庫(kù)方式,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • 以tensorflow庫(kù)為例講解Pycharm中如何更新第三方庫(kù)

    以tensorflow庫(kù)為例講解Pycharm中如何更新第三方庫(kù)

    這篇文章主要介紹了以tensorflow庫(kù)為例講解Pycharm中如何更新第三方庫(kù),文章介紹有詳細(xì)流程,需要的小伙伴可以參考一下,希望對(duì)你的學(xué)習(xí)工作有所幫助
    2022-03-03
  • python如何判斷IP地址合法性

    python如何判斷IP地址合法性

    這篇文章主要為大家詳細(xì)介紹了python如何判斷IP地址合法性,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-04-04

最新評(píng)論

木里| 岳西县| 葵青区| 洪湖市| 盐池县| 马公市| 百色市| 浪卡子县| 屯留县| 蓬溪县| 西乌珠穆沁旗| 建湖县| 伽师县| 宣恩县| 航空| 井研县| 鸡泽县| 绥芬河市| 盈江县| 玉环县| 连州市| 太康县| 枝江市| 蒙山县| 都江堰市| 江都市| 尚志市| 漳浦县| 定陶县| 崇州市| 资兴市| 大竹县| 奉节县| 红原县| 洪雅县| 三穗县| 万源市| 宁都县| 阜南县| 石柱| 高清|