Hello everyone.
In this video tutorial we will see how we can train Yolo V8 on custom dataset of potholes.
So the first step of training YOLO V8 on any custom dataset is to collect the dataset.
So I have found this pothole image dataset on kaggle.com.
So first thing you need to do is to go to Kaggle and create an account if you wish to download any dataset
from Kaggle.
So I have already created my account.
So in the first step I will download this dataset from here.
So I will just click on download.
For the dataset.
It might take few minutes or seconds to get downloaded.
So I will wait.
Well know the dataset.
It can be downloaded.
So will just go to this dataset over here.
And just copy this data set.
And here I have created a folder for this project.
So I will just paste this dataset over here and just unzip it that this dataset.
So I'll click on extract files.
So okay, so it might take few seconds to extract.
Okay, so we have the dataset.
Okay over here, but the dataset is not annotated.
So we first need to annotate this dataset.
So the dataset is quite large.
It consists of around 620 images, so that is fine for this for the training process.
So first of all, to annotate the dataset, I will go to roboflow.
That's right.
Right.
Roboflow on Google.
And just open this first link over here.
And just click on sign up.
Okay.
So in the first step, we need to create an account.
I will sign in with.
So the first step, I will create an account over here.
I don't have account, uh, on this email on roboflow.
So here I'm just creating an account from start.
Arcade.
So let's see.
It might take a few seconds, so let's see and wait and see.
Okay.
And so confirm your account in full.
Accept the terms of service and policy.
Continue.
I would need to follow the same steps.
Please don't skip any of the steps you.
Then you might face an issue.
Okay, so here is my voice.
So what are what you will you be using this workspace board for the academy purpose workspace name and
I can write my name and going sir.
Okay.
And click on continue in one, then skip this step and then for community purpose.
Okay, That's cool.
And then you need to go to the settings.
And then click over here and you need to make sure that your workspace is on the public plan.
So if your workspace is not on the public plan, if it's on some other plan, then you will not be able
to export the dataset or annotate the dataset over here.
So please make sure that your workspace should be on the public plan.
Okay, so now I will go to the robot flow again and create new project.
Okay.
And now.
Okay.
So basically I am performing pothole detection, so I will just go click on object detection.
So if you are performing instance segmentation or semantic segmentation, you can click from here or
choose the required option from here.
So what are you detecting?
I'm detecting potholes.
Okay.
So project name.
Pothole detection.
Yolo v eight.
So this is the name of our project and click on Create Public Project.
Okay, So first of all, we need to select files.
We need to annotate.
So as you know that we have downloaded the dataset from Kaggle, we need to annotate the dataset.
So I will click on select files.
And will go to your gallery.
It was from here.
I will just go to.
Was that us?
So here from here, I'll just click on here and then click on archive and then select all.
And then I will upload these files over here.
So it is processing.
So it will be uploading all the files over here.
So after uploading these files then I will annotate each of the image in that in this dataset.
Okay.
So I'm just pausing the video until this processing completes.
Then I will be back here.
The processing of files is done.
So now I will save and continue so that these images are uploaded into my dataset section over here.
Okay.
But you can currently see that we have 608 images and all are not annotated.
Not a single image is annotated and we will annotate all these images.
So first I will click on Save and Continue.
So that all these files are uploaded.
Then I will show you how you can annotate each image over here.
So it might take two seconds or a few minutes to upload these files.
So will stop.
Pause this video and as these files get uploaded, then I will be back.
Guys.
The files are uploaded so it after the files upload are uploaded it appears there which is for annotation.
So currently, as I told you that the image are not annotated, so we need to annotate each of the single
image.
So as I am only one that is working on this project, so I will assign it to myself.
But if you have other group member or a team member who is working this project with you, then you
can invite that teammate with through his email and he can also help you to annotate these images.
So currently I am the only one working on this project, so I will annotate these on these images.
Okay, so.
Here.
Now you can see the uneducated and those you annotate will appear here annotated in the annotated section.
So I will just click on this first one.
Okay.
So you can see this part over here.
So I will just click over here bounding box tool and just draw this over here.
Okay?
So enter here.
Right.
Pothole.
So basically, our class name will be potholes and save.
Okay, so I can also see a pothole over here as well.
So I will draw this bounding drops around here and save this as well.
Okay, so I don't see any other pothole in this complete image.
So let's move towards the next image.
Well, I can see a big pothole over here, so I will just draw a bounding box over here as well.
You can see that.
Okay.
And then click on Save and Enter.
Okay.
So you can just see over here that we have that drawn the bounding box around this pothole and labeled
it as well.
So now go to the another image, the third one, as you can see, a big pothole over here.
So just annotate it.
And just see.
Okay, just click on Save and you can see that we have labeled pothole.
Now let's move towards the next image.
So there is also a big pothole, so let's label it.
Okay.
And then click on Save Enter and you can see that we have the bullet potholes.
Then go towards the next image as well.
So we can see a lot of potholes over here.
So let's annotate each of them.
Okay.
And that's click on Save Enter, then go to this one and then click on Save, Enter, and then select
this one and then click on Save Enter.
Then select this one and click on Save Enter.
Then select this one.
Click on Save, Enter and select this one as well and click on Save Enter.
So in this way I will annotate all the single images in in this folder.
So there are total 608 images.
So I will annotate every single image.
Okay.
So after I annotate all these single images, then I will go to add five images to my dataset.
For example, currently I've annotated five images, so I need to annotate all these 603 images, but
just to show you as you've annotated five images.
So I will click on Add five images to dataset, and here you can select that train valid test plate.
So basically we take 70% for the training, 20% for the validation and 10% for the testing.
So if you click on Add images over here, you can see that it might take few seconds, so please bear
with me.
Pandemic.
So you can see that our data set now has five images.
Okay.
Uh, currently three in the training.
And.
Okay.
So three in the training, one in the validation and one in the test.
So our dataset total has five images one, two, three, four, five.
So in the same way I will annotate this remaining 603 images and then I will also add them into my dataset.
So let's annotate on these images.
Okay?
That's one thing I want to tell you.
For example, if you're if you don't have the image dataset, you have some YouTube video.
Okay.
So how you can separate a image frame by frame from the YouTube video.
Let me explain this to you as well.
Well, I have found this image of a video of potholes on YouTube, but just by writing pothole roads
and I just found this video in the top search.
So just open this video so you can see that in this video.
We have also have potholes like in this video.
So if we want to if we have a less dense site or insufficient dataset so we can collect a dataset from
videos as well.
So you can just need to copy this from here and just add this link over here and just go to over here.
So please wait while we, while we process your video.
So let's wait until this process, our video, then we can I will show you how you can work on this
video.
So.
So big we can have one output.
145 images from this video.
If we get a one images one frame in each second like this video is around two minutes, 24 seconds.
So it is around one 44 seconds.
Okay.
The total time span of this video is 144 second.
So in each second, we are getting a single frame of image.
Okay?
So in this way, we are getting around 145 images.
So okay, but as I have already enough sufficient dataset, so okay, so just choosing a high frame
rate.
Okay, but you can choose that one frame per second which is already appearing.
Okay.
So you can see this.
We have some particle images which so we have converted this whole videos into small each frames of
images you can see over here.
So we can also click on Save and Continue.
And annotate these images as well.
And we can also add these images into our dataset as well.
Okay.
So I will be working on these images annotation.
So I will assign these images for annotation to myself.
So now we have two tasks.
Currently.
First, we need to annotate the 603 images which we have already uploaded from our system, downloaded
from Kaggle, and these are the seven images which basically.
Look at these images from YouTube.
So I will annotate all these images.
And let me start annotating this.
And as the as the annotation completes, I will be get back over here and then we will see how we can
export this data set and into the our CoLab notebook and run the training.
So let me do the annotation and then I will back.
Vice.
I am back.
I was able to annotate the images.
So now our dataset consists of 665 images.
Okay, so we have that divided our dataset into train valid and test split.
The 70% of the images are in the training, while the 20% of the images are in the validation and 10%
of the images are in the test set.
Well, next, let's go to the generate section over here.
And so we have total around 665 images and we have.
Click on Continue.
We have taught one class which is of pothole, okay?
And the training set consists of 70% of the images which are for 65.
Validation set consists of 133 images and testing set consists of 67 images.
Okay.
So you can also rebalance it like if you have very few images like 100 or 200 images in our data, in
your data set, then you can make validation around zero and you can make such like 90% of your data
for the training and 10% of the data or 10 to 15% of the data for the testing purpose and make validation.
Zero.
Okay.
So you can also rebalance it if you want.
Okay.
So if here you can add any pre-processing step you want, like if you want to resize the image.
I have resized my all the images into 640 plus 640 because the pre-trained model of YOLO v is trained
on 640 cross 640 image dataset.
So to get best of the results.
So I have resized my images so to 640 cross 640 around.
Okay then I will click on continue.
So if my data set is low, less.
If I want to increase my data set, then you can add augmentation step, which is around to flip your
images in the data set, crop the images in the data set, rotate the images in the data set or saturate
increase the brightness of the images in the data set so it will create duplicate images.
For example, if I click on.
But Abbott a rotation.
Okay.
So it will basically generate from a single image, it will generate two more images which are being
rotated by -15 and plus 15 degree.
Like you can set the rotation from here.
Okay.
So in this way, if you want, you can increase your data set size.
If it is low by augmenting the data set, I will click on continue.
Okay.
So you can see that my data set size is increased.
Like previously it was 665, now I have 1595.
So using just a single augmentation of -15 degrees and plus 15 degree, which will generate two images
from a single image.
It has increased my data set by three times.
Okay.
It will also only increase the training data set.
It will not increase your testing and validation data set.
Please remember it will only increase your training data set.
Then click on generate.
It might take a few seconds, so please bear with me until this process gets complete.
Okay, so I'm also waiting.
So this process gets complete.
So you can see that my training set images has increased because I have applied augmentation step and
now it's 1300.
While the validation and testing set, it hasn't changed.
Okay, so I can start training from here as well.
I can train also train on Roboflow, but it's better to train on the Google CoLab.
So to export.
So if you want to train on Roboflow, you can just click on Start Train.
It will do the training and as the training completes, you will get an email that a training has completes
and you can test your model over here as well on Roboflow as well.
But we will test our model on Google CoLab.
I'll always like some coding work, so I will click on export.
I just like the format as YOLO v5 PyTorch format.
They can continue.
Basically, you can also select a PI torch format, but Ultralytics has also released YOLO V5 so you
can select the YOLO V5 PI torch format as well.
And just you need to copy this.
From here and you will get be able to export this data set into your Google CoLab notebook.
So in the next part, we will see how we can train our dataset, our custom model on path Potholes dataset
in Google CoLab.
So let's see you all in the next video tutorial.