This video will be building a CNN model for classification of dogs and cats.
That means we have a need as it begins to which has several images of dogs and cats.
And we want to build a CNN model for classification.
So firstly, what we have done is we have imported that into floor for importing the packages which
are Americans in the first set, and then Frampton's of Loadout garage dog models.
We have imported the sequential model which is there, and the letters which we have imported as dense
convolution to flatten drop out and Max pulling to the garage, preprocessing of image.
We have imported the image data generator.
We've also included the US library, nonbiased and me and matplotlib by spiritedly for the visualization
of image.
Next, what we are doing is loading the data by downloading the data set, which is there.
So actually we are downloading the data set with the help of the United.
And you can also use if you want to download the data or else you can download the data.
The link is mentioned, not a website tutorial.
Also, you can download it from there.
Then we have extracted the part that spot to zip the prosecutors get file.
We want to get the file.
The file we want to get as cats and dogs or zip origin is you order an ecstatic was to true because
we are extracting this particular fight then the path we have given for that only we have imported those
Lababidi which is there that is always taught by the joint.
We have given the directory bodiless path to Zipp in this particular variabilities store.
And what we want to name the file is we want to name the files Cat and dog filter.
So this will be our NIMO file NextRadio.
Then you can see the data downloading Isme and download it from the Google webpage or convert Gatson
Zip.
Then we have a trained directory and a validation directly.
That means strangelet is having samples of images which are required for training the particular CNN
model, whereas the validation directory is used for the further on testing and then checking the accuracy
and the loss which is there.
So for that, we have joined the party of that particular site in the path in the green folder.
And similarly for validation, Daltry also is the joint validation.
Next, what we have done is now we have categorized with the directory of our training, the cat pictures,
now we have divided both the directress that is a clean set of cat pictures, a train set of dog pictures.
Similarly, a validation set or the testing set of cat pictures and the validation set of dog.
That is the testing set of dog pictures, which will be this for that we have done the training also.
So now what we have done, we have imported the packages which are there and we have loaded the data
by downloading the dataset.
Next, what we have done is understanding the data that that means to know that how many particular
pictures are there in each of the dataset.
So for that, what we have done, we have checked the length of all these photographs which are there,
then we have added the total train, which is there.
That means the Gethard, which is death, plus the dopier.
That will be the total train set and the validation will be named next year plus.
Now, Gacha, that will be making the validation set.
And here I have printed all the variables which are there have printed them by executing the simple
print statement so that you can see that total training get images, a thousand total training dog images
are also thousand, and the total validation cat images are 500 and total dog images for validation
are also 500.
That sums up to that the total training image lost out in the year 2000 and 500 per 500 is the total
sort of validation of cat and dog images that sum up to 1000.
So what we're going to do here is we have actually printed the total images which are there in a set
of training and validation.
Next, what we have done, we have created the batch size, the box and the image iten that we have
done that next is data preparation, that raw data preparation is required.
Just now.
We know that particularly firstly, we need to scale our set of data so that only we have included the
image do to generate images.
It generates the batch of BENZER image data with the real time data, augmentation and augmentation
we discuss in our next video.
Right now we just have to think that this particular image and it actually changes the tension of image
might rescaling.
So we have done the research, getting the data for our training data also and for testing.
They don't know how and what we have done.
We have given the backspace directly.
That means you want to brain imaging data flow from directly, which is the chevallier close to do that
mean every time you print a set of badges is that you get a different image for that only was to do
because it passing from the train data generated classman is binary by the classman is binary because
the classification is done only on the basis we can say 011, let's say easy to forget and one for dog.
So that's why the class model is binary as we are discussing about the binary classification model of
a cabin dog.
Similarly, we have done for this is we have done for the train set of images and this we have done
for the validation set of images of each other.
So you can see that I execute the cell that found 2000 images belonging to Douglass's and found thousand
images belonging to two classes that we have seen.
Also not best in plain sight of the display did that 2000 images for the training set, which is that
10000 images for the validation set.
So that is only printing.
Next, what we're going to do and visualize the training set of images which are there.
So visualizing what we have done, sample training images there, and that is N and next is a function
actually used for training, data generated.
That means every time a sample image will be visualized will pass through this particular brain agenda,
which we have created and the Chavalit was to do.
That's why you get a different set of values.
So let us see that.
Firstly, with help of inside that, what is the size Assizes 128.
And there's no doubt, I guess because of that size which we have given it 128 next what we have done,
we have defined a particular function here.
You can see def blocked images and it is having image eot as its argument.
Then we have plotty supplied, which is then an axis.
We can flatten it now in the Zeph folder, which is that it's going to show that image which is there,
the first image it's going to display and it's going to actually display the five.
We can say a bit it off one point five Colomer.
The images will be placed in each column.
Axis equals two.
That means we're not quite a negative axis, which is their tight.
And then people do not show this is the function which we have defined.
And when I call this particular function and sample training images that we give, so it displays us
the first five images, which are the.
Here you can see the first five images of the cat and dog, which are later displeases, so look carefully
these particular images.
Then I'll execute this particular function.
And again, it will display me another set of five images.
Why?
Because every time the training set generates its botsford the brain data generator and trained it agenda
there, Charlie goes to do so again, execute all these three said in the visualization of data.
And there you can see that now it's the new set of data we just did because it is Scharpling on, we
seen the next of the data that we use the next function, which is that next what we have to do is build
a model.
Now we need to build a model.
And I think this particular sequence is quite well.
I learned to you by now we have built so many models, so we have given the name.
We have lowered the sequential model in the variable name model.
Firstly, we have given the convolution to deliver.
We we have 16 now.
The 16 depends actually.
The filters, which will be debt free exercise of religion banning same activation function is RELU.
That means if there is any sort of negative value that will be turning to zero and the positive values
are left unaltered in input, shape and sizes, the image, height and weight and the color component,
which is the next.
We have added the max pooling there also again, a convolutional layer, not when the sequence of convolution
and Max Klingler are actually added.
This actually is known as the stacking up of players, which we discussed while we're doing the basic
scene.
And similarly, we have added this and the last thing the Denslow, we have only one node on, which
is that.
So, OK, this is our models built model that combined.
We know the optimized is required all the rates which are this optimizer.
We use the Adam and lastly of Cardoso's binary crossing from logic sequence to true, why we're using
here binary garçon, because we're dealing with 091 classes only the class having to labels only.
That's the Gaden Doug and Madrases.
This accuracy fogie this is also done next is model, not somebody that we need to bring the summary
of the models that you can actually visualize the layers in the input, shape and size, which is the
next.
What we have done now with the epochs, which are there's a model for data we have used in steps.
Burbach will be trains are divided by the bad side, which is there that is 128 synagogue's.
To give this particular signal.
E-books will start on execution and it will take a few minutes of time.
Now you can see that all the box execution has completed.
Now what I'm doing is saving my model and I'm naming my model as my model Scattergood HFA.
So this is how I can save the model.
I can load it anywhere.
But I have a particular dataset so that I have to not keep on executing the Époque.
Next, what we are doing is we actually know plotting a graph, which is the for that accuracy based
on which we have taken.
And I think we have mentioned a variable historian Edward.
Planning and executing the epochs and then what we have done, we have plotted the subplot, which is
there firstly in the training accuracy and the validation accuracy which is there.
And the second plot which we have plotted is about training, loss and validation loss.
And as execute the cell, you can see the graphs which are here, firstly the training and validation
accuracy which is there, the training accuracy is quite good.
But while we're validating the accuracy somewhat around 70 percent we can see and the training and validation
lost, we can see the training loss is decreasing, but the validation loss is a bit more.
So now we need to actually train our model in a very good way, in an efficient way.
So for that, we will do augmentation.
Now, what is augmentation and how can we implement that in order to several changes?
We need to do will in the upcoming video.