第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何從數(shù)據(jù)庫(kù)中為 Facial_Recognition 創(chuàng)建變量

如何從數(shù)據(jù)庫(kù)中為 Facial_Recognition 創(chuàng)建變量

一只萌萌小番薯 2021-12-21 16:59:16
我試圖能夠從具有名稱(chēng)和圖像文件名的數(shù)據(jù)庫(kù)中提取數(shù)據(jù),然后將其放入face_recognitionPython 程序中。但是,對(duì)于我使用的代碼,程序通過(guò)調(diào)用具有不同名稱(chēng)的變量來(lái)學(xué)習(xí)人臉。如何根據(jù)數(shù)據(jù)庫(kù)中的數(shù)據(jù)量創(chuàng)建變量?有什么更好的方法可以解決這個(gè)問(wèn)題?first_image = face_recognition.load_image_file("first.jpg")first_face_encoding = face_recognition.face_encodings(first_image)[0]second_image = face_recognition.load_image_file("second.jpg")biden_face_encoding = face_recognition.face_encodings(second_image)[0]
查看完整描述

1 回答

?
汪汪一只貓

TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊

您可以使用數(shù)組而不是將每個(gè)圖像/編碼存儲(chǔ)在單個(gè)變量中,并從for循環(huán)中填充數(shù)組。


假設(shè)您可以將文件名從first.jpg, second.jpg...更改為1.jpg, 2.jpg... 您可以這樣做:


numberofimages = 10 # change this to the total number of images

images = [None] * (numberofimages+1) # create an array to store all the images

encodings = [None] * (numberofimages+1) # create an array to store all the encodings


for i in range(1, numberofimages+1):

    filename = str(i) + ".jpg" # generate image file name (eg. 1.jpg, 2.jpg...)


    # load the image and store it in the array

    images[i] = face_recognition.load_image_file(filename)

    # store the encoding

    encodings[i] = face_recognition.face_encodings(images[i])[0]

然后您可以訪問(wèn)例如。第三張圖像和第三個(gè)編碼是這樣的:


image[3]

encoding[3]

如果無(wú)法更改圖像文件名,您可以將它們存儲(chǔ)在字典中并執(zhí)行以下操作:


numberofimages = 3 # change this to the total number of images

images = [None] * (numberofimages+1) # create an array to store all the images

encodings = [None] * (numberofimages+1) # create an array to store all the encodings

filenames = {

    1: "first",

    2: "second",

    3: "third"

}


for i in range(1, numberofimages+1):

    filename = filenames[i] + ".jpg" # generate file name (eg. first.jpg, second.jpg...)

    print(filename)

    # load the image and store it in the array

    images[i] = face_recognition.load_image_file(filename)

    # store the encoding

    encodings[i] = face_recognition.face_encodings(images[i])[0]


查看完整回答
反對(duì) 回復(fù) 2021-12-21
  • 1 回答
  • 0 關(guān)注
  • 126 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)