In this video, we're going to create our first CNN model.
For dog and cat dataset that we discussed in our last lecture.
We have over 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 expect that you will get free folders, ice cream and validation.
Each of these folders contain two soap folders, cats and dogs.
And in this folders, you can find the images of cats and dogs that we are going to use for a lot more
than.
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 over images as well.
Now we have around 4000 different images.
We will use to Kosen images for training.
We will be called polls and images for our testing purpose, and we will take another posehn images
for our relevation data say.
Now, before starting, we will save the location of this spoilers in three variables that are green
territory validation directory and text directory.
So just.
Copy.
The address of this four years.
And save it and this three different variables.
Now, if you are coping, you will get backward slash instead of forward slices.
So just remember to put R before pasting this folder addresses.
So we have saved addresses of all these four letters and three different variables, train directory
validation category and asperity.
Now we have to convert this picture images in the form of values.
The first step to do this is to read the picture fine, then decode the JPC, contain two RGV grit's
of pixel.
So we want three channels red, blue and green.
Then we need to convert this RGV floating point values and what value between zero and one.
So to do all these steps we will use get us inmates data generator module.
This module have functions to perform, all these steps using the single function.
Paul.
Let's just import image detergent.
Victor Modu.
Now, there are two parts of this.
Inmates do the generator module.
First is to get the image and then the second part is to reskill that image.
You can feel the images from directly from numb by erry or from any other source here.
In our case, we want our images to directly feed it from a directory or a formula.
So we will be using flow from directory method of image to tagine record.
So I have created this train, the Dudgeon Object from IMS data generator.
And here.
As an argument, we are providing the rescaling value to be weighed RGV values by 255.
Our RGV values lies between zero to 255 and to convert them and to zero to one interval, we have to
divide that by 250 by.
So first, we are creating an object with data to function with reskilling value of one divided by 255.
Then we are using flow from that to my truck.
Since our data is in the form of Faldo's or decreased.
Then we are creating two different generators, one for our train data and another one for our valuation
data.
For train data, first we have to mention the train directory.
We have already saved the information on forward train that to address in this train directory 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 our image sizes are not centralized, we are a serializing 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 floor from that tree will feed images in the Betties or twenty two over train generated.
Then we have to provide information that base content in the form of folders.
So since we are doing binary classification and we have two four years, one Fourcade and one for DOT,
we have to provide last more as binary.
The output of this green generator will be in the form of X variables and the VI variables Y labels
will depend on the name of the formulas.
So if we have cats and dogs as our four year.
So what viability will will automatically become.
Cats and dogs for all the images that are inside those four wheelers.
Now, let's three ways what this train the narrator is doing.
First.
We are going into a train directory.
There are two for us there.
Cats and dogs.
We are resizing all the images in the shape of one foot by one foot pixels.
We are feeding images in the batches of 20.
So at the time, we are picking 20 images.
Then to create wine 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 last more
as binary.
Then as a result of this function, we will have over images in the form of floating point ten sets
with RGV values between zero and 255.
This is the kind of data we used in our last video.
Then we are reskilling those Excel values between zero and one.
And that's why we are dividing it back 255.
Now, why we have created this train, do dudgeon object?
This is because instead of directly feeding all the data and blow it a fixed function, we are going
to feed 20 images at a time and do our fit function while training over model.
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 Rescale, Zoom, Schirò, etc, to generate some more data
from our existing data.
If you want some more detail about this email, do to generate a.
You can click on this link to open that, get us documentation.
So here you will get all the information you need for inmates, people siccing.