In this video we are going to create our first CNN model for dog and cat boots like that we discussed
in our last lecture.
We have our data in the form of jpeg images.
You can download this images from the links that we have provided in the resources section of this video
once you download the zip file and extract it.
You will get three folders this crane and validation each of this for years content do so for years.
Cats and dogs.
And in this folders you can find the images of cats and dogs that we are going to use for our model
one thing you can straightaway notice is that the dimensions of this images are not standardized so
you can see this is a portrait image.
And this is a landscape image.
So we have to resize our images as well.
Now we have around 4000 different images.
We will use 2000 images for training.
We will be called a thousand images for our passing purpose and really take another posing images for
our validation data site
now before starting.
We will save the location of this four years in three variables that are creating directory validation
that victory.
And as directory so just copy the address of this for years and save it.
And this three different variables.
Now if you are copying you will get backward slash instead of forward slices.
So just remember to put art before pasting this folder addresses
so we have saved addresses of all these four letters and three different variables drain directory validation
category and aesthetically
now we have to convert this picture images in the form of values the first step to do this is to read
the picture file then decode the debate contain to already be great of pixel.
So we want three channels red blue and green
then we need to convert this art be floating point values and to a value between 0 and 1 so to do all
these steps we will use gave us image data generator module
this module have functions to perform all this steps using a single function or legacies in both image
data generator module.
Now there are two parts of this image.
Do the generator module first is to get the image and then the second part is to reskill that image
you can feed the images from directory from num by array or from any other source here in our case we
want our images to directly free data from our directory or the formula so we will be using Flo from
directory method of image to to generate the so I have created this green detergent object from immediately
the generator.
And here as an argument we are providing that scaling value to divide our GDP values by 255.
Our RTP values lies between 0 to 255 and to convert them and 2 0 to 1 interval we have to divide that
by 255.
So first we are creating an object with data generator function with reskilling value of 1 divided by
255.
Then we are using slow from Derek through my texts and so if data is in the form of folders or decreased
then we are creating two different generators one for our train data and another one for our validation
data.
For train data first we have to mention the train directory we have already saved the information of
forward train that is to address in this train that a key variable.
So first parameter here is our variable which contains the directory name.
Then the second parameter here is the size of images that we want.
So since a word image sizes are not centralized we are centralizing it using the target size of 150
by 150 pixels so all of our images are going to convert in this size.
Now we have to mention the bed size that we are going to use in our model.
So earlier if you remember last time we were using a bed size of 64.
Now we are using a bed size of 20.
Now this flow from Derrick tree will feed images in the batches of twenty two hour train generated then
we have to provide information that is contained in the form of four letters.
So since we are doing binary classification and we have two four letters one for cat and one for dog
we have to provide last more as binary
the output of this green generator will be in the form of X variables and the via variables via labels
will depend on the name of the four years.
So if we have cats and dogs as our four year
so what virally will will automatically become cats and dogs for all the images that are inside those
four wheelers.
Now let's revise what this strange and neuter is doing.
First we are going indoor green directory.
There are two four letters there cats and dogs.
We are resizing all the images in the shape of 150 by 1 4 pixels we are feeding images in the batches
of 20.
So at the time we are picking 20 images then to create via labels we are using the folder names.
And since there are two folders and it's a binary classification problem we have to grow it class more
as binary then as a result of this function we will have our images in the form of floating point ten
sets with arbitrary values between 0 and 255.
This is the kind of data we used in a what last video then we are reskilling those pixel values between
0 and 1 and that's why we are dividing it by 255.
Now why we have created this train do Dudgeon object this is because instead of vertically feeding all
the data and blow at a fit function we are going to feed 20 images at a time and to our first function
while draining over more than one of the advantage of using this image data generator is that in case
we want augmented data we can directly apply many more functions like Greece scale zoom shear cetera
to generate some more data from our existing data if you want some more detail about this image do to
generate a you can click on this link to open the graphs documentation so here you will get all the
information you need for image people assessing.