All right, so what we've done so far is preparing the season with all its players, we have configured
our like propagator.
Next year, we need to manipulate the images that we are about to load later.
So far, we've not had any image library, so we did not add them in yet.
So first here, I just want to prepare my data to be manipulated in order to enhance the learning in
my CNN.
OK, to do that, I am going to create a valuable it's called the trained.
Data generated, and it's going to equal a function called eMESH.
Data generator.
OK, and here we are going to specify what exactly are we going to do with our images?
Well, I just want to do two very simple things.
The first one is horizontal flip.
The other is vertical flip.
So I'm going to try horizontal underscore.
Flip equals true.
And I'm going to type vertical.
Philip.
Equals.
OK, by that, every image I'm going to load, it's going to try a variety of orientation, foget it
could be flipped horizontally or vertically.
Now, if you Google this image data generator, you will see a lot of manipulation that we can do little
together.
If I open a browser and I just type in image data generator and if we go to the keywords image data
generator.
This is called data augmentation, and we can do multiple stuff, we can do a rotation, we can do a
shift so we can shift it left and right, we can do some shear, we can do some zoom by certain amount.
There is a lot of stuff that we can do.
It depends on the data we have.
And, well, you can try multiple things and see what works for you.
But for now, we're going to stick to these to all.
OK, now what's next is it's time to load our data.
So far we did not load anything.
We are just preparing the model and will not bring actually any image from our midst data set.
OK, so how are we going to do that?
Remember, we need to split our data between training and testing.
So we have two sets that we need to create and we need to load.
Now, if you, let's say, go to the database we have.
So this is a database we have, as you can see, there was testing folder and there is a training folder.
Now let's see how many are in testing.
Let's see how many images.
You could see that there is around nine hundred eighty, let's say, for label zero nine hundred eighty
for training, if I check the zero, you'll see around 6000.
So you always want to split your data so that around between 50 and 20 percent are in the testing and
80 percent of your images should go to the training.
Now, remember, we have two phases.
First phase is we pass training data and we tell the model that, OK, this is the result and it should
compare it.
But in the testing, when we pass the testing data, we don't give it the answer and we don't let it
actually compare.
We just take the result.
And by taking the result of the prediction, we can generate the accuracy we are looking for.
So it's going to calculate what is the accuracy of this model from the testing data.
Again, training data is used to train the model and we give it the final result at the other end of
the season.
And we thought, OK, this is a zero zero.
It's predicted drunk.
It tries to calculate the error function and it adjusts the weight in the testing you the data, you
don't tell it the answer.
You get the answer from the prediction and you calculate the accuracy.
OK, so split should be 80 percent training or 85 percent training and the rest is testing.
OK, that was a very small recap.
Now, how are we now?
How are we going to load the data?
Well, let us first create a valuable skill training set.
OK, now we are going to call the following method on this class.
It's called train decision.
And we call a method which is called flow from directory.
And as the name suggested, we are going to load our data as a training set from a directory.
The first thing you want to give is what is the path?
If we go here to our dataset, wherever you have downloaded it, you can just simply copy the path here.
So how can you copy a path?
It's very simple, right?
Click and copy that.
Now we just paste it here.
This is my training directory right now, I need to pass other data so Ikoma and let us press steps
until we are here.
And let's add the second argument.
Now, we could have written them all on the same line, but this is not really practical for reading.
OK, next is dog its size.
What does this mean?
Well, this should actually match the input shape because here we are trying to load data with this
function is going to scale it and it's going to send it to the sequential later.
OK, so scaling is happening here and we need this size here to match the size you otherwise are going
to get compilation error or interpretation error.
OK, so target size should be twenty eight by 28.
I don't need to provide the channel because it doesn't matter, right?
We are just scaling the size of the image.
Next, we have the batch size.
It means that every batch we are passing, how many images does it contain?
Every batch we are passing to our CNN.
So let's say we are passing 32.
Next, now you need to specify that this is a gray scale, so color mode equals due to Tatian gray scale.
OK, now let's say that your image is colored.
You don't need to specify all of this color.
It's by default.
So you don't need to do that.
But since our images are gray scale, we need to specify that explicitly.
Now, here we have said Channel one, which means it's a great scale.
But here in the flow from the rectory, we need to pass it as a color note.
OK.
All right.
Next of a color mode comes class mode.
Now, class mode here depends on what kind of classification are we doing.
Let's say I had only one class.
And I just want to say, if it's this number of zero or not, then the class mode should be binary,
right?
Because it's either a zero or a one.
Right.
But in my case, I have multiple categories.
I have zero one, two, three up to the number nine.
That's why we need to specify that I have multiple labels here.
And the way to do that is by saying class mode is categorical.
OK, what's next now with Puddicombe?
And next, we have this upset of the subset is going to tell this function here, this method here,
that is this for training or is this for validation?
So in my case, this is my training, right?
This is my training folder.
All right, so we are done from the first one.
Now, I'm going to copy the whole thing here and I'm going to do the same thing for the testing now.
This was for training, copy everything and based now I'm going to rename this to Test Set.
And the function name is the same, we need also here to change it to the right directory.
So go back to the folder, right click copy path.
And this is the path for our testing.
OK, 28 28.
Correct.
Matches the same.
All the same.
Now, the subset you need to turn into validation.
This is for testing.
OK, now, by that, we had to prepare the function that will bring all of our image data sets.