Using facial similarity search project with a different dataset

I really enjoyed Lesson 5 in this course. But one thing that bothered me about the demo was that Princess Diana died when she was younger than Prince William is now, and so I wondered if that might have caused the results to skew in favor of Charles (dad).

I wanted to try the same approach using King Charles III as the child and his mother (QEII) and father (Prince Philip) as the mom and dad, since they both lived well into their 90s and whose lives were well documented in photographs.

Both the original and my ‘extension’ were very fun projects. I’ve consumed (literally) mere pennies of the $100 Pinecone allotment after running both the original project locally and fiddling around with my modified version with QEII et al. In working through the example, I found the first 5-6 courses in the OpenCV University Bootcamp [Free Official OpenCV Course - OpenCV University] very helpful.

FWIW, I offer this write-up and the attached PDF for others in the community as another example. Here’s a summary of steps:

  1. Using Anaconda, I set up an environment (ai-ml) and installed all the libraries specified by the various imports.

  2. I registered at Pinecone and obtained a key. At first, I used the “free” account key, but realized that I needed a Serverless key. To obtain that key, I created a serverless account at Pinecone. By providing credit card information, anyone can get $100 worth of Pinecone serverless credits. (I’ll keep a watch on my consumption so that I don’t rack-up a huge bill).

  3. I downloaded my Pinecone key to my local system. It’s contained in a plaintext file (saved as .env) that looks as follows:

Note: For any keys that you’d like to use across multiple projects locally (eg., for these many short courses), a more robust approach is to export the keys in one’s profile. To learn how to do so with OpenAI API key, see OpenAI Developer Quickstart > Step 2. Set up your API key.
4. At this point, I’m able to run the Jupyter Notebook locally, on my own Ubuntu machine, using the images of Diana, Charles, and William.

  1. I moved all the images of present-day King Charles II into a new child folder.

  2. For the dad and mom folders, I had to obtain jpg images of both Queen Elizabeth II (QEII) and Prince Philip. For this task, I used the BBC website and found photos of QEII and Prince Philip from her various ‘jubilee’ celebrations and many other events over the years. After downloading as many photos from various years as I could find, I then used gimp to crop the images to just faces. [As with the original dataset for the project with Diana et al, this dataset with QEII et al seems a bit out of balance: There are very few pictures of Prince Philip as an infant, toddler, pre-teen, or teen. But I stopped the process arbitrarily when I had 42 images of Philip (because it was taking way too long and was very tedious! [1] ]

[1] If anyone has ideas about how to expedite/automate image-gathering, I’d love to learn them!

The results are shown in the PDF (attached). As with the original, the resemblance between father and child is stronger than that of mother and child. Perhaps that makes sense intuitively, since men typically might look more often look more like other males in the family, and women typically look more like other females in the family (just my opinion).

Lesson_5_Facial_Similarity_Search_QEII-etal.pdf (371.0 KB)