<p>You can use the idea of face-embeddings, which for example is proposed in the highly-cited paper <a href="https://arxiv.org/abs/1503.03832" rel="noreferrer">FaceNet</a> and implemented in <a href="https://cmusatyalab.github.io/openface/" rel="noreferrer">OpenFace</a> (which also comes pre-trained).</p>
<p>The general idea: take some preprocessed face (frontal, cropped, ...) and embedd it to some lower dimension with the characteristic, that similar faces in input should have low euclidean-distance in the output.</p>
<p>So in your case: use the embedding-CNN to map your faces to the reduced space (usually a vector of size 128) and calculate the distance as in the euclidean-space. Of course you also cluster faces then, but that's not your task.</p>
<p>The good thing here besides the general idea: openface is a nice implementation ready to use and it's homepage also explains the idea:</p>
<blockquote>
<p>Use a deep neural network to represent (or embed) the face on a 128-dimensional unit hypersphere.</p>
<p>The embedding is a generic representation for anybody's face. Unlike other face representations, this embedding has the nice property that a larger distance between two face embeddings means that the faces are likely not of the same person.</p>
<p>This property makes clustering, similarity detection, and classification tasks easier than other face recognition techniques where the Euclidean distance between features is not meaningful.</p>
</blockquote>
<p>They even have a comparison-demo <a href="https://cmusatyalab.github.io/openface/demo-2-comparison/" rel="noreferrer">here</a>.</p>
Face comparison (Not recognition or detection) using OpenCV and Keras?
<p>First of all here is my <a href="https://github.com/alucard001/OpenCV-Face-Recognition-and-Comparison/blob/master/Open%20CV.ipynb" rel="noreferrer">github link for the question</a>.</p>

<p>And here is my question:</p>

<p>I would like to do a face comparison function using Python.  And I can successfully(?) recognize faces using OpenCV.  Now, <strong>how do I do the comparison thing</strong>?</p>

<p>What I understand is this:</p>

<p>In general Machine learning approach, I need to gather lots of data about that particular person and finalize it using a CNN.  </p>

<p>However, I just got 2 images, how do I do the comparison?  Should I think it in terms of classification or clustering (Using KNN)?</p>

<p>Thank you very much in advance for all your help.</p>