Classifying Cats & Dogs images with AutoML Vision

This gave me the idea to work with a similar dataset.Also, my brothers were highly fond of pets (especially cats and dogs), and I thought deploying this model would be something fun for them to play with too.Working in Keras, the process would typically require me to (1) find and label the dataset; (2) train a ML classifier; (3) deploy the ML model; & (4) use a REST API to create a server to call the ML classifier on the web.That’s why I experimented with Cloud AutoML — as I only needed to perform step 1 above!Dataset: Images of Cats and DogsFortunately, finding a suitable dataset for this purpose wasn’t a tenuous task..I keyed in “kaggle dogs and cats dataset” and this link popped up as one of the search results on Google..I selected 150 images of cats and dogs individually and imported these images onto the Cloud platform..After which, I labelled each image either as a “Dog” or a “Cat”.Uploading a total of 300 images for the model (150 each for cats and dogs respectively)Training and EvaluationThe next step is to train the model..By default, AutoML Vision splits the dataset randomly into 3 separate sets when training the model.Training Dataset: 80% — used for trainingValidation Dataset: 10% — used for hyper-parameter tuning and deciding when to stop trainingTest Dataset: 10% — used for model evaluation15 minutes later, the model was trained and evaluating the model, I found the following:Precision and Recall values for the ModelThe precision and recall scores were 100% — what does these mean?.From all the test examples which were assigned a cat/dog label, all of them were actually accurately categorized..And, from all the test examples that should have the cat/dog label assigned, all of them were actually assigned that correct label.According to the confusion matrix, the ML model was able to accurately classify all the photos (100%)..Not that confusing after all.Prediction with new imagesNext, I tested the ML model with new images..The dataset I downloaded actually came with more than 10 000 images, so I picked an image of a dog and another of a cat at random and uploaded these images into the model.I uploaded an image of a cat for prediction, and the model was able to predict with 100% accuracy that it was indeed a cat!Also predicted with 100% accuracy that it was a dog!Even with the new images, the model predicted well.I was not convinced, though..So I looked on the internet for images of Sphynxes — these were a breed of cats with a high physical semblance to dogs..I wondered if the ML model would be confused with this image.Sphynxes — a breed of cats that resembles dogs; I was mildy surprised to find out that the ML model was still able to classify this 100% with a “cat” labelOkay turns out that the model was still able to predict with 100% accuracy that this was an image of cats.But….what if we had both a cat and a dog in the same image?Looks like the model got a little confused here — but this is definitely something for me to work on.How about the facetious Chihuahua versus Muffin Challenge?You might have seen the ‘Chihuahua vs Muffin’ meme going around on the internet — here..Given the high similarity of how a chocolate chip muffin (could be a chocolate chip cookie too, on hindsight) with a chihuahua, I wanted to test if the model could tell this apart.Looks like it got fooled.. More details

Leave a Reply