Since I’m still waiting on the parts I ordered, I decided to do some work that doesn’t require them. I have absolutely no idea if that’s the right approach or whether I’m going on the right direction as finding information on the internet around edge topics like this can be quite difficult, so I decided to just go with what make sense to me and adapt as needed.
Cutting to the chase: I decided to start working on the face recognition bit of Matilda, as I mentioned before, she will be able to recognise faces and most importantly she should be able to distinguish a person to another, I found a few good articles on the internet, in special this one that explains thoroughly how this actually works. After reading the article I figured this was too hard to be coded by one person and that a team out there must have done it, so I started looking for API’s and open source projects, luckily I found this article.
The example code already contains an XML database with patterns for identifying faces, but it clearly needs improvement. Take this image I chose as an example, the AI is finding faces on things that aren’t really faces and is also skipping a few faces in the background:
Based on that I changed the code a little and I am now cropping the image in the position where it finds a face and saving it on a ElasticSearch database. I will then manually validate these images on ElasticSearch and flag the ones that aren’t faces so that later on, I can also have the AI check on the database for similarities and try to validate against, that will possibly remove these false positives. Most importantly: I have no idea how to achieve that yet.
I decided to save these images as Base64 on ElasticSearch, I am not sure if that’s even the best format to store them, but if this exercise amounts to nothing, at least I am practising Python and ElasticSearch which I have meaning to do for ages now.
Here’s the code for that:
I didn’t polish this code at all and it’s not actually done, the goal is to have it read from a directory where I will have thousands of pictures containing faces, so the app will go one by one examining and saving faces into ElasticSearch. I read there are photo databases I can download, that’s the next step, when that’s done I’ll add the code into a proper Github repository and share my findings in a new post.
#### Update! ######
This experiment failed miserably lol
Base64 is definitely not a good choice for several reasons, to start with, the base64 of a JPG image is completely different to the base64 the same image saved as PNG. So what I read is that I need to analyse the image and save the important aspects of it, not too sure how I’m going to approach this yet, but apparently is also a good practice to convert the image into grey scale as it reduces a lot of unnecessary noise when analysing it. I’m getting information from everywhere I can find but I’m having a hard time understanding some concepts, it feels like I’m lacking some of the fundamentals, I’ll focus on something else whilst researching this on the side for now