Python in Python: Building a Snake Classifier Using Deep Learning

Cody | Oct 24, 2023 min read

Snakes… Why did it have to be snakes? — Indiana Jones

To be honest, it didn’t start with snakes; it all started with clouds.

As I moved through the first few chapters of the Practical Deep Learning for Coders course, I found myself looking for a good beginner project. I’ve always had an interest in meteorology — I even minored in it years ago. The logical choice was to take something that I love and apply my newly-learned skills to it.

However, I burned hours that turned into days trying to force my model to work. I was getting error rates of 40-50%. The culprit? My dataset. This being my first project, I dove straight into building the app before I thought my idea all the way through. I was excited to get back into Python and create a script to scrape images of clouds from the internet to start training my model. I started with cumulus clouds — you know, the big fluffy ones. Strike one: I forgot that not only do clouds have types but they are also classified by height and have different sub-types. Strike two: I relied on the data to be somewhat correct; it’s on the internet after all.

I spent my time trying to clean the dataset and correctly classify all of the cloud images. I was frustrated and losing interest in the project when one of my kids burst into my office, telling me there was a big snake in the driveway. I asked him what type of snake, to which I received a shrug and a guess. As I relocated the Southern Black Racer from the driveway to the woods, it hit me: I should build a snake classifier, or at least attempt to build one.

It turned out that building a dataset for snakes was much easier than clouds. So I picked three types of snakes:

  1. A terrifying and deadly snake, the Coral Snake.
  2. A snake that looks dangerous but isn’t, the Corn Snake.
  3. A snake that we see around the yard, the Black Racer.

So far, this model is only trained on these three types of snakes. Feel free to test it below by uploading a picture of one of these snakes or use the built-in examples.

I’ll post about how I made the app and trained the model at some point but I wanted to share what I learned while doing my first project in the hopes that it might inspire someone to push past a blocker.