Hi and welcome back.
So in this section, we'll be taking a look at video classification and what video classification seeks
to do is that you have seen that something is happening like imagine you're watching sports, so you
know, like a football game is going on or bullying game or perhaps you're watching someone in action
movie shooting a gun.
Those are different actions, and you can classify video as a key and classify each frame by what action
is going on.
So let's take a look at how we can create a CNN art and architecture network that can actually take
scenes of a video and classify them correctly.
So let's go into this notebook 66.
And again, this is from the official Keros tutorial that side.
This one is bit by, say, a pool, and what we'll be using is the USB-C one to one data set, so you
can take a look at what a data set is.
It's basically a bunch of different actions or scenes like archery, whatever that is.
Yeah, it's a dual.
It's a drum, lunges, typing different things as usual.
So you have all these different scenes going on, so you have tons of clips of each scene.
And then basically we have to create a classified to classify what's happening in each scene.
So let's take a look at how we do that.
So firstly, we what we do, we need to add TensorFlow doc.
So we just install that there takes about 30 seconds.
Next, we need to download a subsample version of the original dataset because it's quite big.
So we just downloaded the top five classes, just five different classes here.
But we'll be using next week to import our functions, sort of the libraries and then define some type
of parameters to any books that size.
Image size.
Some standard stuff there.
Then we need to prepare data.
So this is how the dataset labels on this trend.
Ozzy Osbourne tests.
And you can take a look at what it looks like here.
You can see each video, each a file, and there are many of them has a cloud tag and the targets punch,
punch, tennis, swing, playing cello, whatever.
So you can take a look of basically some of the challenges and the new networks.
You can read about this blog post here.
Different things.
What's going on?
So anyway, back to the lesson.
So what we have now is some functions you'll be using.
So props and the square function, as well as a video function that uses some open TV functions to load
that video frame by frame.
Then we have to get the features out of it.
So we use the Inception V Tree model, which is trained on the image now dataset to extract features
from our network.
So, so we get that model here to sort of feature extractive model.
Next, we have a pair of string lookup that just basically gets tags right here for labels.
Then we have a function that prepares all of the videos here, and then we can create this test data
and training data and associated labels right there, and you can see the size.
So we have 594 different videos or labels.
Well, essentially the data points in this.
So now I should warn this above code here to prepare all of the videos takes quite a while.
It takes about 20 minutes to run.
So I've run that before, but just please be patient.
I mean, 20 minutes isn't that long, but it does take a while.
Now we have to create a sequence model.
So remember, this is an hour and then CNN based architecture.
So we have the class would have here that we load and we have our basically our sequence are an end
model going on right there.
And then basically we can just start running the experiments and remember we use the features and sequence
in this model to predict.
So we trained this model for 10 epochs, doesn't take very long at all, and we get an accuracy of 53
percent, which is OK.
What pure guessing would have been 20 percent because it's five different classes.
And no, we can actually run some inferences on that.
So let's run an inference that takes a sample.
VIDEO A random sample then does a sequence prediction on it and then creates a GIF after.
And then basically, you can print the label out here so you can see this video, which is clearly boxing
or punching.
You can see it gives two percent probability prediction that it's a punch.
So that's quite good.
Cricket shot tennis swing against their will and swinging motions.
So which playing cello and cheering bit of vacancy and got it right, even though it isn't as sure as
it should be?
It did get it right.
So that's pretty good for just such a quick training so you can do a lot more.
You can take some of the advice here for next steps to see if we can get better accuracy, as well as
try different samples of a data set.
If you want to get more data to train.
Remember to remember it takes a while to process that.
So that's it for this video classification in the next section, we'll take a look at using Transformers
to do the exact same thing.
So I'll see you in the next lesson.
Thank you.