Hipster or Homeless — Can AI tell the difference?

Source: Deep Learning on Medium

I know there is no need for such an AI model in the real world… but who cares? It’s a fun way to try Teachable Machine for a couple of minutes! 😉

Collect training data

To fetch some example images for the training, we can use an extension called Fatkun Batch Download Image. This extension makes it pretty easy to download all images returned by an image search in Google. Just enter your query, e.g. “hipster man beard”, and hit the download button. It will create a folder labeled with your query inside your download folder.

Repeat this step for some queries and put all downloaded images into two separate folders called “hipster” and “homeless”.

Ethical Bias

Please keep in mind that we, the people who train neural networks, are responsible to keep ethical bias in mind! When you’re doing a search for “homeless guy”, there are a lot more images from persons of color. This is a sad truth… and could lead to unintentional results, where our model decides the class based on the color of the persons skin.

You are the one who is responsible to augment the training data and prevent ethical biases!

Think about these cases and try to keep it balanced by searching for “homeless white male” and “hipster black female” etc.

Training the model

To train our model, we just have to drag and drop all files from each class into the corresponding class in the UI. In my case, there were 430 images of hipsters and 276 images of homeless people. Google will handle image cropping by itself.

In a real datascience project, you should try to avoid an imbalanced dataset for your classes whenever possible. I went with it anyway, because I was eager to see how Google would handle it and how the performance would be.

When you’re ready, just hit the “Train Model” button and let it run! This should not take longer than a couple of minutes, even on old hardware.

Training Statistics

In the model section, we can find an entry called “Under the hood”. This will reveal some useful informations, e.g. the accuracy per class und some graphs, how our model has evolved over the training period of 50 epochs.

Accuracy of our model after training

For our small dataset, we were able to achieve a pretty high accuracy score of 97% for hipsters and 88% for homeless people. Not bad for such a small sample set!

Evaluate results

Now the most interesting part! Let’s have a look what our model thinks about some images, which were not part of the training set. Below you can see the results for 6 examples. The only one which was not pretty clear is indeed Hagrid from Harry Potter. I am not sure by myself, how I would label him…