My Classifier Thought a Cat was a Hotdog.

I’ve started Fast ai’s Intro to deep learning course last week. And I’m finding it great so far. I writing this to encourage who’s curious about deep learning to give FastAi’s course a try. You only need a a laptop and intermediate programming skills to get started. With just a laptop you can create some relatively sophisticated models.

After a few lessons I decided to create a simple image classifier that can take an image and classify it as a hotdog or not hotdog. So the end results should look something like this:

This image has an empty alt attribute; its file name is image-1.png

The first step to train a model is to get data. I used Bing’s search image api to find images to train my model. Using Bing I created a dataset of hotdogs, burgers and pies. I grouped them into two groups: hotdogs and not hotdogs.

First results

After training my model. I tried to upload a picture of a hotdog and it predicted it correctly:

Image of a pizza and results from the classifier: Prediction: not hotdog & probability 0.9989

Then I tried a Pizza, and it worked:

Image of a pizza and results from the classifier: Prediction: not hotdog & probability 0.9649

Then I threw a curveball at my classifier and uploaded a cat:

Image of a cat and results from the classifier: Prediction: hotdog & probability 0.9970

It thought the cat was a hotdog. And confidently thought it was a hotdog.

This illustrates a good point about Deep Learning: Predictions are probabilistic. The model has no real intuition about a hotdog like a human does.

I looked through the my data base and I found that there were a lot of dogs within the model. I sourced my images from Bing’s image search. Obviously a some dogs turned up in the search term “hotdog”. And cat looks similar to a dog so I guess my classifier thought it was a hotdog.

The culprits: Dogs in my hotdog dataset!

I’m going to rerun the classifier by moving the dog pictures out of the hotdog database and into the not hotdog classifier

It still thinks the cat is a hotdog but at least its less confident. Progress! I’m still just two lessons into the course as of November 2020 so I don’t know how to solve this problem completely. So I’m going to stop here.

I hope I showed you deep learning is within the reach of the average person and encourage you to pick it up! And if you are interested I definitely recommend you to look into fast ai’s free course.

%d bloggers like this: