This Python computer vision project is a minimal level of difficulty to get computer vision to work well. Overfitting in computer vision, in part, has to do with our deep learning models learning the a shape it's recognized is in a certain position in the picture. To solve this we can use Tensorflow's ImageDataGenerator.
This will require us to work with a Tensorflow dataset which can be a little tricky at first as it works differently than a Pandas DataFrame. The benefit of working with Tensorfow's ImageDataGenerator outweighs the added difficulty.
We will be able to augment our images on each epoch as we connect Tensorflow's ImageDataGenerator to the folder with our images and on each epoch of training your deep learning model the generator will pull in the images and augment them on the fly.
Basically, you can keep training for a very long time model for a very long time and it will keep improving as each epoch it is training on new images and will allow you to increase the accuracy of your test predictions.
Let's code along together in this TensorFlow follow-along guided project with a template and solution workbook and predict the Rock, Paper and Scissor image from Kaggle. Learn how to code a Computer Vision deep learning model with Tensorflow.
Send data science teacher brandyn a message if you have any questions
We will use Tensorflow's ImageDataGenerator to augment one batch at a time and we can see here how it slightly changes the images. Play with the amount of augmentation. The trick is to find out how much you can do.
The trick to computer vision is to set up the connection with the file path to the folder with your images so that Tensorflow's ImageDataGenerator and pull and augment the images on each epoch.
Set up the generator object that will we use as we train our model. This uses the TensorFlow function flow_from_directory the we use with the file path created above.
Here's we will build a simple convolution deep learning model. We'll start with the Conv2D layer in Tensorflow.
Let's fit our Tensforflwo Convolutional deep learning model.
We will go through how to predict using a Tensorflow dataset created from the ImageDataGenerator .
Comments