<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Saina Ghosh on Medium]]></title>
        <description><![CDATA[Stories by Saina Ghosh on Medium]]></description>
        <link>https://medium.com/@sainaghosh2411?source=rss-c9d3242577ac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*7Xoty4RIwU6AxuxF.jpg</url>
            <title>Stories by Saina Ghosh on Medium</title>
            <link>https://medium.com/@sainaghosh2411?source=rss-c9d3242577ac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:01:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sainaghosh2411/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to create a Face Recognition Model using FaceNet Keras?]]></title>
            <link>https://medium.com/clique-org/how-to-create-a-face-recognition-model-using-facenet-keras-fd65c0b092f1?source=rss-c9d3242577ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd65c0b092f1</guid>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[feature-extraction]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[face-net]]></category>
            <category><![CDATA[face-recognition]]></category>
            <dc:creator><![CDATA[Saina Ghosh]]></dc:creator>
            <pubDate>Fri, 10 Jul 2020 08:50:18 GMT</pubDate>
            <atom:updated>2020-07-10T08:50:18.912Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GUuai4d0nayJbWFt.jpg" /><figcaption><a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.theverge.com%2F2017%2F9%2F21%2F16332760%2Fai-sexuality-gaydar-photo-physiognomy&amp;psig=AOvVaw1km-Lz45W2qE1uSIOxEBs2&amp;ust=1594457100891000&amp;source=images&amp;cd=vfe&amp;ved=0CAIQjRxqFwoTCNjplNylwuoCFQAAAAAdAAAAABAV">Image link</a></figcaption></figure><p>Google’s deep convolutional network — FaceNet proposed in 2015 by Google Researchers overcomes the hindrance of implementing face verification and recognition efficiently at scale and achieved the state of the art results. The authors introduced us to the concept of harmonic embeddings, and a harmonic triplet loss, which describes different versions of face embeddings (produced by different networks) that are compatible with each other and allow for direct comparison between each other. FaceNet is the backbone of many opensource systems such as FaceNet using Tensorflow, Keras FaceNet, DeepFace, OpenFace.</p><p>Let’s begin talking about what actually face recognition is?</p><p>Face recognition is a technique of identification or verification of a person using their faces through an image or a video. It captures, analyzes, and compares patterns based on the person’s facial details. The face detection process is an essential step as it detects and locates human faces in images and videos.</p><p>Identification means to compare your identity to all the identities present in the database. Whereas, verification refers to a comparison of your identity to a particular match in the database.</p><p>Let’s understand this with an example. Suppose you are entering your office which has a face recognition system. Here, the system will compare your face with all the other faces residing in the company’s database(i.e., One to Many match). This is known as identification. Now, we’ll consider unlocking our devices with face recognition. Here, we are comparing our live face with our stored face in the devices’ database(i.e., One to One match).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*S0PKPQwUG8adPiOHFSuhyg.jpeg" /><figcaption>Identification vs Verification:[1]</figcaption></figure><p>The complete Face Recognition system can be divided into three categories :</p><p>1. Face Detection</p><p>2. Feature extraction</p><p>3. Feature Matching</p><p>Basically, the output of one method is taken as an input for the next method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*BUT2eBx0RpZi7vtzZIzrvw.png" /><figcaption>Face Recognition Flow:[2]</figcaption></figure><h3>Face Detection</h3><p>The Face detection method is used to find the faces present in the image, extract the faces, and display it (or create a compressed file to use it further for feature extraction).</p><h4>Methods used in Face Detection:</h4><blockquote>1. Haar cascade Face Detection</blockquote><blockquote>2. Dlib (HOG) Face Detection</blockquote><blockquote>3. Dlib (CNN) Face Detection</blockquote><blockquote>4. MTCNN Face Detection</blockquote><p><strong>Haar cascade Face Detection:</strong> This method has a simple architecture that works nearly real-time on CPU. Also, it can detect images at different scales. But the major drawback is that it gives false results as well as it doesn’t work on non-frontal images.</p><p><strong>Dlib (HOG) Face Detection: </strong>It is the fastest method on CPU which can work on frontal and slightly no-frontal images. But it is incapable of detecting small images and handling occlusions. Also, it often excludes some parts of the chin and forehead while detection.</p><p><strong>Dlib (CNN) Face Detection: </strong>It works very fast on GPU and is capable to work for various face orientations in images. It can also handle occlusions. But the major disadvantage is that it is trained on a minimum face size of 80*80 so it can’t detect small faces in images. It is also very slow on the CPU.</p><p><strong>MTCNN: </strong>This method gives the most accurate results out of all the four methods. It works for faces having various orientations in images and can detect faces across various scales. It can even handle occlusions. It doesn’t hold any major drawback as such but is comparatively slower than HOG and Haar cascade method.</p><p>You can refer <a href="https://www.learnopencv.com/face-detection-opencv-dlib-and-deep-learning-c-python/">this site</a> to get the detailed understanding of the above differences.</p><h4>COMPARISON ( Watch The Difference ):</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*adBdtjLXgTsCpFCGgqYreA.png" /><figcaption><a href="https://i2.wp.com/therighthairstyles.com/wp-content/uploads/2013/12/17-razored-shag-haircut-for-round-faces.jpg?w=500&amp;ssl=1"><strong><em>Haar Cascade</em></strong></a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*m2X87vHO9nrQs7kCV50A7w.png" /><figcaption><a href="https://i2.wp.com/therighthairstyles.com/wp-content/uploads/2013/12/17-razored-shag-haircut-for-round-faces.jpg?w=500&amp;ssl=1"><strong><em>MTCNN</em></strong></a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*Ep0V7M9JZD7lAGOl46mZqA.png" /><figcaption><a href="https://i2.wp.com/therighthairstyles.com/wp-content/uploads/2013/12/17-razored-shag-haircut-for-round-faces.jpg?w=500&amp;ssl=1"><strong><em>Dlib (HOG)</em></strong></a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*p4X_V75U9zCqDPg-5UVrLQ.png" /><figcaption><a href="https://i2.wp.com/therighthairstyles.com/wp-content/uploads/2013/12/17-razored-shag-haircut-for-round-faces.jpg?w=500&amp;ssl=1"><strong><em>Dlib (CNN)</em></strong></a></figcaption></figure><p>Hence, we will be using the MTCNN Face Detection method.</p><p><strong>Libraries to install:</strong></p><p>1. NumPy</p><p>2. Matplotlib</p><p>3. PIL</p><p>4. MTCNN</p><p>5. Sklearn</p><p>6. Keras</p><p><a href="https://drive.google.com/drive/folders/1o7-0I3jkZbngGIs9NCjwnFkLRpj-QMW2?usp=sharing">Link to dataset, compressed files and pretrained Model file</a>.</p><h4>CODE:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f493449e8e54ac03359f4f58db98e9d/href">https://medium.com/media/3f493449e8e54ac03359f4f58db98e9d/href</a></iframe><h3><strong>FEATURE EXTRACTION</strong></h3><p>Feature extraction is the basic and most important initializing step for face recognition. It extracts the biological components of your face. These biological components are the features of your face which differ from person to person. There are various methods which extract various combination of features, commonly known as nodal points. No two people can have all the nodal points similar to each other except for identical twins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*Up8jmGtpWud9M7aAOERa9A.jpeg" /><figcaption><a href="https://bloximages.chicago2.vip.townnews.com/journalstar.com/content/tncms/assets/v3/editorial/4/3a/43a2fd30-0b2c-53a7-9555-caf176e90714/511844d50da37.preview-620.jpg"><em>80 Nodal Points(Landmarks)</em></a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a6kXOpZQ4abIk0EfIkKOpw.jpeg" /><figcaption><a href="https://hackernoon.com/hn-images/1*wh1N-kogDMaZYS17lqyqeQ.jpeg"><em>128 Face Embeddings</em></a></figcaption></figure><p>Facial Feature extraction has two approaches:</p><h4><strong>1.</strong> <strong>Shallow Approach</strong></h4><blockquote>1. PCA (Dimensionality Reduction Method)</blockquote><blockquote>2. LDA (Dimensionality Reduction Method)</blockquote><blockquote>3. Cosine Similarity (Feature Matching)</blockquote><blockquote>4. HOG</blockquote><blockquote>5. SIFT</blockquote><h4><strong>2.</strong> <strong>Deep Approach (Industrial Giant Nets)</strong></h4><blockquote>1. VGG</blockquote><blockquote>2. Face Recognition API</blockquote><blockquote>3. FaceNet Keras</blockquote><p><strong>PCA</strong>: PCA is used to reduce the dimensionality of the data. In PCA, the original features of your dataset will be converted into a linear combination of uncorrelated variables(features). These combinations are known as Principal Components. PCA increases algorithm performance and improves visualization. But for reading the PCA components, you need to standardize the data otherwise it won’t be possible to find the optimal Principal Components. Also, PCA results in loss of information if the number of Principal Components is not selected wisely. <a href="https://medium.com/@mansiarora_20448/feature-extraction-principal-component-analysis-a10705b330ce">Learn more</a></p><p><strong>LDA</strong>: LDA is a dimensionality reduction technique used to classify different classes based on the features of the supervised data. The major drawback of LDA is the so-called Small Sample Size (SSS) Problem and non-Linearity problem. SSS Problem occurs when the sample (training dataset) is quite small as compared to the dimension of the data.</p><p><strong>Cosine Similarity:</strong> The measure of cosine angle between two vectors is known as the cosine similarity between two vectors, the closer the cosine value to 1 and greater will be the possibility of a match. One vector among the two vectors is the test data (detected face) and the other is the vector of the training dataset (one of the detected faces of train dataset). But it gives false results for sparse numeric data.</p><p><strong>HOG: </strong>HOG only uses magnitude values of pixels without including the neighboring values which lead to the extraction of improper features during image rotation.</p><p><strong>SIFT: </strong>SIFT is relatively alike to a sparse descriptor. Sparse Descriptor is a technique that initially detects the key points in the image and then generates descriptors at these points. SIFT consists of scale rotation and affine transformation properties as well. But it requires a long-running time as compared to other systems.</p><p><strong>VGG: </strong>VGG uses various architectures such as VGGFace1, VGGFace2 by Keras. The basic difference among these models is the number of layers included in its architecture that varies from model to model. These models have quite a good accuracy. <a href="https://towardsdatascience.com/extract-features-visualize-filters-and-feature-maps-in-vgg16-and-vgg19-cnn-models-d2da6333edd0">Click here</a> to learn about VGG16 and VGG19.</p><p><strong>FaceRecognition API: </strong>FaceRecognition API is easier to use. It has a much easier architecture to implement with some inbuilt libraries required for feature recognition. You need to upload a picture and call the FaceRecognition API. The API then simulates the browser using the user’s information to call the recognition points. It works well in real-time and holds good accuracy.</p><p><strong>FaceNet Keras: </strong>FaceNet Keras is a one-shot learning model. It fetches 128 vector embeddings as a feature extractor. It is even preferable in cases where we have a scarcity of datasets. It consists of good accuracy even for such situations.</p><p>We will be using the FaceNet Keras Model.</p><h4><strong>CODE:</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2707b842b62aabfca4cace5f4b1f0a52/href">https://medium.com/media/2707b842b62aabfca4cace5f4b1f0a52/href</a></iframe><h3><strong>FEATURE CLASSIFICATION</strong></h3><p>Feature classification is a geometry-based or template-based algorithm used to classify the features of the test data among different classes of facial features in the training data. These template-based classifications are possible using various statistical approaches.</p><p>The well-known methods used in feature classification can be given as:</p><blockquote>1. Euclidean Distance</blockquote><blockquote>2. Cosine Similarity</blockquote><blockquote>3. SVM</blockquote><blockquote>4. KNN</blockquote><blockquote>5. ANN</blockquote><p><strong>Euclidean Distance: </strong>It is a distance-based feature classification method that calculates the distance between the facial nodes and the face which has the minimum difference between these distance values is considered to be the match. But it is suitable for the datasets having a smaller number of classes and lower dimensionality features.</p><p><strong>Cosine Similarity: </strong>In cosine similarity, the solution that we obtain after calculating the cosine of an angle is brought into concern. Here, we would compare the differences between these results. The more the value is closer to 1, the greater is the probability of the match. But it may give a false result if the test data features are incomplete (i.e. if the resultant value is 0 then the features don’t match, and if nearly all the features match then the value is 1).</p><p><strong>SVM: </strong>SVM (Support vector machine) creates an optimal hyperplane to classify the classes of training dataset based on the different features of the face. The dimensionality of the hyperplane is one less than the number of features. Different kernels can be applied to see what features are used by the classifier to remove the features if required. This can help to improve speed. <a href="https://towardsdatascience.com/svm-feature-selection-and-kernels-840781cc1a6c#:~:text=A%20Support%20Vector%20Machine%20(SVM,both%20classification%20and%20regression%20purposes.">Click here</a> for detailed understanding.</p><p><strong>KNN: </strong>KNN (K-Nearest Neighbor) is all about the number of neighbors i.e. the k value. In KNN, if k=3 then we check that the data is close to which 3 data points. Thereafter, it is decided that the majority of closest data points belong to which class. Now, the test data is predicted to be in this class KNN has curse of dimensionality problem which can be solved by applying PCA before using KNN classifier. You can get a better understanding of KNN <a href="https://www.datacamp.com/community/tutorials/k-nearest-neighbor-classification-scikit-learn">here</a>.</p><p><strong>ANN: </strong>ANN (Artificial Neural Network) uses a very detailed algorithm for face recognition. It classifies the local texture using multi-layer perceptron for face alignment. It uses geometric feature based and independent component analysis for feature extraction and multi artificial neural network for feature matching. This is the best method to use. You can get a detailed understanding of ANN for Face Recognition in <a href="https://www.hindawi.com/journals/aans/2011/673016/">this paper</a>.</p><p>Here, we will be practicing the SVM method.</p><h4><strong>CODE:</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a418451d106db9b84fad6510b0f61434/href">https://medium.com/media/a418451d106db9b84fad6510b0f61434/href</a></iframe><p>Face recognition has many usages such as access control, shopping online, finding lost people, tracking down criminals, etc. But with this comes the requirement of accuracy, surveillance angles which can be effectively fulfilled by Keras FaceNet.</p><p><strong>REFERENCES:</strong></p><p><strong>[1] </strong><a href="https://www.bayometric.com/identification-verification-segmented-identification/">https://www.bayometric.com/identification-verification-segmented-identification/</a></p><p><strong>[2] </strong><a href="http://blog.altabel.com/2018/08/14/facial-recognition-technology-where-is-it-being-used-and-how-does-the-technology-work/">http://blog.altabel.com/2018/08/14/facial-recognition-technology-where-is-it-being-used-and-how-does-the-technology-work/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd65c0b092f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/clique-org/how-to-create-a-face-recognition-model-using-facenet-keras-fd65c0b092f1">How to create a Face Recognition Model using FaceNet Keras?</a> was originally published in <a href="https://medium.com/clique-org">Clique Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>