vgg 名人人脸图像库_您看起来像哪个名人? 图像相似度搜索模型
vgg 名人人臉圖像庫
People often try to look like a celebrity they like the most. They always seem to love it when they get compliments like…
人們經(jīng)常試圖看起來像他們最喜歡的名人。 當(dāng)他們得到諸如……的稱贊時,他們似乎總是喜歡它。
“Hey, you look just like that guy from the Interstellar movie, OMG, what’s his name…??? Yes, MATTHEW MCCONAUGHEY!!”
“嘿,你看起來就像星際電影中的那個家伙,OMG,他叫什么名字??? 是的,MATTHEW MCCONAUGHEY!”
Meanwhile…
與此同時…
nydailynewsnydailynewsMaybe your friends were just being polite to make you feel good, but is there a way to objectively identify which celebrity you resemble the most?
也許您的朋友只是彬彬有禮,使您感覺良好,但是有沒有一種方法可以客觀地確定您最喜歡哪個名人?
In this post, I’ll use a Siamese Neural Network approach to calculate a similarity percentage(0–100%) between two images by comparing facial features.
在本文中,我將使用暹羅神經(jīng)網(wǎng)絡(luò)方法通過比較面部特征來計算兩幅圖像之間的相似度百分比(0–100%)。
介紹 (INTRODUCTION)
Comparing images for similarities has far and wide-reaching applications. Some use cases for matching images can be found in the field of healthcare, where radiology reports could be compared with stock images of some medical condition in order to assist doctors in the diagnosis of diseases.
比較圖像的相似性具有廣泛的應(yīng)用。 可以在醫(yī)療保健領(lǐng)域找到一些匹配圖像的用例,可以將放射線報告與某些醫(yī)療狀況的庫存圖像進(jìn)行比較,以幫助醫(yī)生診斷疾病。
In retail where an image of a product might be searched on an e-commerce website for price and availability details and in general search applications for looking up an image in a database of images. Such a task is far from trivial as images of similar objects might appear different due to differences in camera equipment, lighting conditions, image orientation, color, and resolution.
在零售中,可以在電子商務(wù)網(wǎng)站上搜索產(chǎn)品圖像以獲取價格和可用性詳細(xì)信息,并且通常在搜索應(yīng)用程序中用于在圖像數(shù)據(jù)庫中查找圖像。 這樣的任務(wù)絕非易事,因為由于攝像設(shè)備,照明條件,圖像方向,顏色和分辨率的差異,相似物體的圖像可能看起來有所不同。
There have been many algorithms that have been proposed for matching images, such as SIFT, Pyramid Match among others. Recent advancements in Convolutional Neural Networks (CNNs) have enabled direct comparison of images without the use of handcrafted features that were earlier used to compare images.
已經(jīng)提出了許多用于匹配圖像的算法,例如SIFT,金字塔匹配。 卷積神經(jīng)網(wǎng)絡(luò)(CNN)的最新進(jìn)展使圖像的直接比較成為可能,而無需使用以前用于比較圖像的手工功能。
Siamese networks are typically used in this domain, they are a special type of neural network architecture. Instead of a model learning to classify its inputs, the Siamese networks learn to differentiate between two inputs. It learns the similarity between them.
暹羅網(wǎng)絡(luò)通常用于此領(lǐng)域,它們是神經(jīng)網(wǎng)絡(luò)架構(gòu)的一種特殊類型。 暹羅網(wǎng)絡(luò)不是在學(xué)習(xí)模型來對其輸入進(jìn)行分類,而是在兩個輸入之間進(jìn)行區(qū)分。 它了解它們之間的相似性。
數(shù)據(jù)集 (DATASET)
The dataset used for this exercise is taken from FaceScrub, which is a face dataset built by detecting faces in images returned from searches for public figures on the Internet, followed by automatically discarding those not belonging to each queried person. It comprises a total of over 100,000 face images of male and female 530 celebrities, with about 200 images per person. The name and gender annotation and the pixel values of the faces of celebrities inside the images are also included in this dataset.
此練習(xí)使用的數(shù)據(jù)集來自FaceScrub , FaceScrub是通過檢測Internet搜索公共人物返回的圖像中的人臉,然后自動丟棄不屬于每個被查詢者的人臉而構(gòu)建的人臉數(shù)據(jù)集。 它總共包含100,000幅530位男性和女性名人的面部圖像,每人約200張圖像。 圖像中名人的名字和性別注釋以及面Kong的像素值也包含在此數(shù)據(jù)集中。
數(shù)據(jù)預(yù)處理 (DATA PREPROCESSING)
- Discard all black and white images, and keep on the colored images, for consistency. 丟棄所有黑白圖像,并保留彩色圖像,以保持一致性。
- For the sake of simplicity (and because of the limited computation power I had), only 20 images per celebrity were used for training. 為了簡單起見(并且由于我的計算能力有限),每個名人僅使用20張圖像進(jìn)行訓(xùn)練。
- Crop out the faces of celebrities from the images. 從圖像中裁剪出名人的臉。
- Resize all the images to a 150X150 resolution (RGB images) for a consistent input size. 將所有圖像調(diào)整為150X150分辨率(RGB圖像),以獲得一致的輸入尺寸。
- Randomly applied a contrast limited adaptive histogram equalization algorithm to the images to improve the contrast. 將對比度受限的自適應(yīng)直方圖均衡算法隨機應(yīng)用于圖像以提高對比度。
- Added additional augmented images on the fly while training the network to reduce overfitting on the training set. The images were rotated randomly from -30 to 30 degrees and flipped. 在訓(xùn)練網(wǎng)絡(luò)時動態(tài)添加其他增強圖像,以減少訓(xùn)練集的過度擬合。 圖像從-30度隨機旋轉(zhuǎn)到30度并翻轉(zhuǎn)。
模型— 暹羅神經(jīng)網(wǎng)絡(luò) (MODEL — SIAMESE NEURAL NETWORK)
A Siamese neural network (sometimes called a twin neural network) is an artificial neural network that uses the same weights while working in tandem on two different input vectors to compute comparable output vectors (Wiki).
暹羅神經(jīng)網(wǎng)絡(luò)(有時稱為雙神經(jīng)網(wǎng)絡(luò))是一種人工神經(jīng)網(wǎng)絡(luò),它在兩個不同的輸入向量上串聯(lián)工作時使用相同的權(quán)重,以計算可比較的輸出向量( Wiki )。
This diagram illustrates how a Siamese neural network works. The two sister networks are identical and share the hyperparameters and weights. Each sister network of the siamese network is fed with a different image and the neural network is trained using triplet loss or contrastive loss. The loss is calculated using the ground truth, i.e. whether the images are similar or not.
該圖說明了暹羅神經(jīng)網(wǎng)絡(luò)的工作方式。 兩個姐妹網(wǎng)絡(luò)是相同的,并且共享超參數(shù)和權(quán)重。 暹羅網(wǎng)絡(luò)的每個姐妹網(wǎng)絡(luò)都收到不同的圖像,并且使用三重態(tài)損失或?qū)Ρ葥p失來訓(xùn)練神經(jīng)網(wǎng)絡(luò)。 使用地面真實性(即圖像是否相似)來計算損失。
The Sister network used here is a SqueezeNet which is an 18-layer Neural network consisting of Convolution, Normalization, Pooling, and ReLU activation layers. In addition to that, it also consists of 8 Fire Nodes as illustrated below.
這里使用的姐妹網(wǎng)絡(luò)是SqueezeNet ,它是一個18層的神經(jīng)網(wǎng)絡(luò),由卷積,規(guī)范化,池化和ReLU激活層組成。 除此之外,它還包括8個火節(jié)點,如下圖所示。
SqueezeNet擠壓網(wǎng) Fire Node火節(jié)點Finally, since the objective of this solution is not to classify but to differentiate between images, a Contrastive Loss Function is used that distinguishes between the input pair of feature vectors. The following is the formula for contrastive loss.
最后,由于此解決方案的目的不是要分類而是要在圖像之間進(jìn)行區(qū)分,因此使用了對比損失函數(shù)來區(qū)分輸入的特征向量對。 以下是對比損失的公式。
X1, X2 are the two input images to the network, X1,X2是網(wǎng)絡(luò)的兩個輸入圖像, Gw is the transformation of the image to the feature vector and Gw是圖像到特征向量的變換, Dw is the Euclidean Distance between the two feature vectors.Dw是兩個特征向量之間的歐幾里得距離。Here is what the final Siamese model training looks like
這是最終的暹羅模型訓(xùn)練的樣子
In the training example above, two celebrity images, Bruce Lee and Jackie Chan, are fed individually to the sister networks. The two output vectors at the end of the Sister networks are then used to compute the contrastive loss, based on the ground truth that these two images are not from the same person. This loss value is then backpropagated to both the sister networks to update their weights equally. Similarly, two images of the same actor will also be fed to the model to help it understand the similarities along with the dissimilarities.
在上面的訓(xùn)練示例中,兩個名人圖像,李小龍和成龍分別喂給了姐妹網(wǎng)絡(luò)。 然后,基于這兩個圖像不是來自同一個人的事實,將Sister網(wǎng)絡(luò)末端的兩個輸出矢量用于計算對比損失。 然后,將該損耗值反向傳播到兩個姐妹網(wǎng)絡(luò),以平等地更新其權(quán)重。 類似地,同一演員的兩個圖像也將被饋送到模型,以幫助其理解相似性和相似性。
輸出值 (OUTPUT)
After uploading a new image, the model returns a list of probability scores calculated against other celebrity images, indicating how similar the two images are. Here is a sample output of celebrity look-alikes for Matt Damon.
上載新圖像后,該模型將返回針對其他名人圖像計算出的概率分?jǐn)?shù)列表,指示這兩個圖像有多相似。 這是Matt Damon的名人相像的樣本輸出。
The model can also be used to compare the similarity between two images as shown below…
該模型還可用于比較兩個圖像之間的相似性,如下所示……
That’s the best similarity score I got with any celebrity…:)這是我與任何名人獲得的最佳相似度分?jǐn)?shù)……:) Johnny Depp(old) vs Johnny Depp(Young) — High Similarity約翰尼·德普(舊)vs約翰尼·德普(年輕)—高度相似 Emma Watson vs Anne Hathaway — Not that similar艾瑪·沃特森(Emma Watson)vs安妮·海瑟薇(Anne Hathaway)—不太相似 Katy Perry vs Zooey Deschanel — Basically Twins凱蒂·佩里(Katy Perry)vs祖伊·德斯香奈(Zooey Deschanel)—基本上是雙胞胎有問題嗎? (GOT QUESTIONS?)
If you have any questions/feedback about the post, please contact me on Linkedin here
如果您有任何疑問/該訊息有關(guān)的反饋,請在LinkedIn與我聯(lián)系點擊這里
翻譯自: https://medium.com/swlh/which-celebrity-do-you-look-like-an-image-similarity-search-model-87539a511c5
vgg 名人人臉圖像庫
總結(jié)
以上是生活随笔為你收集整理的vgg 名人人脸图像库_您看起来像哪个名人? 图像相似度搜索模型的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 磷酸铁锂电池反超三元锂,市场份额达 55
- 下一篇: 三星内存第一30年 闪存第一20年!就看