Hi and welcome back to the course in this lesson, we'll make a very cool OCR capture of.
So, you know, those will be you'll see it, you know, well, with characters they put to prove that
you're a human and they're all messed up and have obscurities and occlusions on them.
Well, that's a capture.
In case you didn't realize and we're going to make a computer vision model or algorithm that can crack
those basically cracking, I mean, figure out what the text is in them.
So it's pretty cool.
So let's get started.
So open notebook 72 and we'll begin.
And I will say this is again a notebook from the official Keros tutorial it's prepared by.
It came in and we will begin.
So first thing that's important are libraries, and now we lure them a capture image datasets.
So to capture image dataset is actually quite simple.
So if you take a look at it here, it's already loaded.
You can see, let's wait for this to load the file names so you can see the file name itself has to
capture decoded already.
So that's sort.
The labels are encoded here, so you can see 05:40, and this one is twenty to five and and so on.
You can see that's it.
That's how it's encoded.
So it's pretty easy and good way to encode OCR data into an image without having a separate labels file.
They just use the final names.
So we looked at data set there.
We just display some things about the image and characters are there.
So we have 19 unique characteristics of the characters present.
These are the number of images and labels found, so everything seems to check out.
These is all image dimensions that we'll be using.
So next we move on to pre-processing part of it.
So this part here you basically have a function called character to No and number two characters.
It maps the images back to the characters and vice versa.
We next split the bits here and we get to extrait and validation datasets right there.
And now there's a function here.
We just step two of processes just to input well and could a single sample so we can pass that image
to the CNN.
That's actually just a CNN with CDC loss, but we'll get a little store that we'll talk about that shortly.
So now let's create our dataset fully here.
So we just have our dataset of pipeline functions here.
So we just load the data and create our validation and entry and the training dataset of its creators.
So now we can just visualize some of the data which you've seen previously when I showed you when I
open up the files individually so you can see what some of them look like.
And now we create a model.
So the model has something that we call CTC layer, and that's a CTC lost layer and that basically considers
the temporal and is a temporal.
I mean this left to right.
Sequence in this image here.
So it basically looks at the different image features each sequence as it goes left to right and if
if it's easy to predict if the characters there or not and then if it knows a character's there, then
it tries to predict what a character is.
If it passes over the entire sequence here so the pieces are, then let's see some type of sequential
temporal input.
You can see it here, the other Elysium to create that.
So CTC loss is a weird connection.
This temporal loss I believe it stands for.
I'm not entirely sure I got that right, but it's a very, very cool way to encapsulate that relationship.
That temporal relationship in a left or right rhythm sequence that is natural for OCR lab tests.
So the model is quite small, as you can see just 400000 parameters, but it's quite powerful.
So now we trained the network here, and it doesn't take too long to train does about four or five minutes.
And then once it finishes training, you can actually run some inferences on it here.
So this is a block of code that allows us to run an inference and predict it so we can just take a look
at some predictions here.
So you can see this gets it totally right and an x twenty five to twenty seven, six and four eight
and it see this what works as well?
This one is 44 x.
It all seemed to be right, which is actually quite good.
It's remarkable.
I was trying to find one that isn't right right now, but I haven't actually found any.
If you do, maybe maybe when you run in that book, we'll get another different sample, hopefully.
I'm not sure if it's random or not.
I haven't checked detailed in the detail in the code, but it most likely it might be random.
So you might get different samples here.
But these are all 100 percent correct, which is quite good for such a simple network that we've created.
So it's a genius.
So that's it for this lesson.
In the next section, we'll take a look at the flask using a flask to create a computer vision API.
So that's actually a very valuable lesson.
And this is a nice demo project to get you started with understanding how you can create your own computer
vision API, so I'll see you in the next section.
Thank you.