Face recognition using siamese networks
We will understand the siamese network by building a face recognition model. The objective of our network is to understand whether two faces are similar or dissimilar. We use the AT&T Database of Faces, which can be downloaded from here:https://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html.
Once you have downloaded and extracted the archive, you can see the folders s1
, s2
, up to s40
, as shown here:
![](https://static.packt-cdn.com/products/9781789534207/graphics/fa81a9a3-3223-4afc-9b1f-f16f27493e4d.png)
Each of these folders has 10 different images of a single person taken from various angles. For instance, let's open folder s1
. As you can see, there are 10 different images of a single person:
![](https://static.packt-cdn.com/products/9781789534207/graphics/35a82793-2730-4951-b24d-7c3d31cc3e1d.png)
We open and check folder s13
:
![](https://static.packt-cdn.com/products/9781789534207/graphics/3e56b831-c7a5-4b87-8770-d41833d2bac7.png)
As we know that siamese networks require input values as a pair along with the label, we have to create our data in such a way. So, we will take two images randomly from the same folder and mark them as a genuine pair and we will take single images from two different folders and mark them as an imposite pair. A sample is...