Train YOLO V8 on Custom Dataset for Object Detection | Licence Plate Detection Model Training

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone this is me Arijit with a new video and in this video we are going to talk about a very interesting project which is custom object detection so in this video I am going to show you how you can use a custom data set to train a custom model in Yolo version 8 so that you can actually detect custom objects now in this very particular video I am going to use the example of license plate detection so I'm going to use a data set of license plates and I'm going to train the model so that it using the model we can detect the number plates but the similar code and a similar template all the similar concept you can use to train any model and I will actually show you how you can change the data set and the some of the parameters to train any other model you want to train now coming to custom object detection the main problem people faces like that is the very first thing is where to get the data set now the next is like which model to which uh model or which architecture to use the third is which libraries to use then there is which version of libraries to use because then there is this version of Library which doesn't works with that version of Library so which version of libraries to use and finally where to train the model let's say I don't have a very powerful machine to where to train the model and to solve all these problems in this video we are going to use firstly Google cool app so you don't need any powerful machine you can train your model in your in the Google app the second thing is I'm going to give you a template you can use that template so here all the libraries with the required version numbers are mentioned so you can actually install all of them in a single line of code and then using the same template you can actually train any model okay so that's all the things we are going to cover in this video so it's going to be a very interesting video so without wasting any time let's get started okay everyone so in this video we are going to do all the things step by step so when uh basically you have to train a custom model the very first thing is obviously you have to find a data set okay or you have to make your own data set now making your own data set that we are not going to cover in this video for that we are going to create a very separate video and maybe the next video we are going to make on that so in this video I'm going to show you how to find a data set because like for most of the normal objects you are going to most of the times you get a data set so how to find a data set and how you can actually get the data set in Google collab and then how to train so that is the main focus so here for that purpose you can actually use Rover flow now in Robo flow you are going to in Rover flow if you go in lower flow you are going to get a lot of models okay so let's say this is the Overflow site and if you go to overflow Universe in this way so this is the link universe.com here you can search for different kind of data sets so for example in our case is license plate so if you just search for license plate multiple data so you will get like there's this one data set you have 2500 images then there is this one okay this one and license so if you give license plate like detection something I think more data steel will get even so you see there is this data set which at seven point five thousand K images uh this one is 1.8 K images and a lot of data sets there not only one multiple data sets are actually there okay so for let's say you want to go for bird let's say okay so if you just search for Bird yeah so there is a data set for word so like for most of the normal objects you will get that you may get editor set here and even if you don't get a data set here in that case also you can actually upload your own data set here and then basically if you can also level it so how to level your own data and how to level your data set that thing will go in a separate video okay but if you already so maybe some from somewhere else you get a label data set okay in that case also you can actually upload the data in Google workflow and from Robo flow is very easy to actually get the data in Google collab so for example in this video I'm going to use this data set okay and this data set actually we have uploaded so one of my teammates has uploaded here so we got the data set from GitHub and from there we have actually uploaded it here okay and if you go if you see there are total 395 images of vehicles and if you see if I just show you any of the image you see all the images are already leveled okay as you can see the images are already leveled so as you can see the classes are this and you can see the license plate is the only class here okay so you can see all the different things and like the raw data and everything from here okay so annotating the data labeling the data maybe we can discuss separate video but our point is that here the data set is level and in Robo flow if you go for any data set most of the data says here you are going to get labeled okay now these are the raw images now if you go to data set you are going to get this that as you can see the data set has been upload the last time it is updated is August 31 2003 so just three days back we have just updated our data set okay now now once you got a data set from receive water data set from Global flow or you got it for somebody else a label data set and you can just upload it in roboclow that also you can do once you do that the next thing is you have to come to data set uh this uh from the menu data set here and there you will see it is going to split your data set into train set valid set and test set so our data set is very small now this is a demo video like how so the purpose of this video is to teach you how you can train a custom model so that's why I have not taken a very big data set so I just shown you like they are all license plate big data set where you have like eight thousand nine thousand images but I'm not going to use that because if you have a smaller data set the time required will be also less okay but even we did this data set also we are going to get a good accuracy I'll show you at the end so this is the train set this is the valid set and is a test set so 78 70 21 percent nine percent is displayed so it will automatically automatically going to split the data set and also it's going to create the folders so so when you will download the data set you will see there is a train folder valid folder and test folder so everything is going to do it for you okay even this free already it's pre-processed so all the images are already stretched to 640 by 640 okay and as you can see no augmentation has been applied but if you want augmentation you can also apply certain number of images will get increased okay now uh I will give you the link of this data set so you just go to this link so if you want to just train the license plate detection you can just go to this link from there you have to just log in it's free you just have to log in and from that all you have to do is you have to download the data set in the specific format so in this video we are going to use YOLO version 8 okay now if you don't know what is YOLO YOLO is like you only look once so basically it's a very good accurate object detection image segmentation model okay and version 8 eventually is very accurate I would say and it is actually made by ultralatics so as we are going to use YOLO version 8 that's why we have to download our data set in this YOLO version 8 format so you just have to click on this and once you click uh you have to go to you don't have to download as if your computer so if you are you are going to train your model in your PC if you have a powerful PC you are going to train it in a computer you can download a zip obviously I'm not going to do it I'm going to train in the model in Google collab so I'm going to do show download code so you just do continue and it will just zip the file it will get the file ready for you and it is going to give you this link so you just have to take the link from here and you have to paste it in your Google collab and you have to just run the code and then you will have the data set so I'll show you so this is the data set part that if you got your data set from Robo flow that's best is very easy just search a data set uh come here in the data set select your model your opportunity in our case and just come here and you just download this code and so one thing is there if you download a very big data set and then you try to upload the folders directly to Google collab it's not going to work Google collab will hang in most of the time so this is a very good way of taking up getting the data set in your Google collab okay and also it's very fast so it takes a very less amount of time to download it in Google app so this is the data set part okay now the next next thing is the code and I already said we are going to code it in our Google collab so this is how Google collab looks like so if your very first time in if you don't know how to Google collab works you can just go for Google app you just have to have a Google account nothing else you can go to Google collab you can create a new notebook and you will get something like this okay now what is very important is I'll just show you so what is very important is uh if you if I show you this is the code you are going to use so here if you see if you go to here the drop down and if you go to view resources there if you're doing it for the very first time what you will see is you are not going to get the GPU Ram so you have to go to change run run time type and there you have to select E4 GPU once you select that then only you are going to get the GPU okay so you have to select the GPU and then only you will get it and after that once you get uh once you select that you just here you will get a reconnect option just click on it and it will get reconnected and you will get something like this a tram dicks and T4 so make sure T4 is written here that means you are getting the T4 GPU without GPU also you can run it but it will take a lot of time so I don't recommend that one okay so this is about the Google Plus setup very simple come here go to come here go to view resources uh change the runtime select E4 GPU click save here I can because I'm already running GPU in my one collapse session I cannot select here but you have just click here save and next you just have to click on connect that's it you are done okay then uh then the thing is uh you have to go to our GitHub repo the link will be in the description as always and there you are going to get the uh collab file also okay so from here so what you have to do is first you have to download this whole GitHub repo in your desktop and from there so let me just uh I'll not do it but I'll just tell you that you just download this because I already have opened this file in cool app you download the whole folder then you come to Google app you click file you click open notebook from there you go to upload you just choose a file and you are going to choose this file this license plate detection YOLO v8.py NB this file you select and once you open this file this is how it will look like you will have all these things there okay now only one thing you have to do what you have to come here that that thing you have to do that you have to go to a drop down and from there you have to go to manage this and view resources and you have to select the T4 GPU so that you will get the GPU here that the only thing you have to do after you open the notebook now let's see what we are doing inside the notebook okay now the very first thing we are doing here is as you can see we are cloning our GitHub repo why we are cloning our data view because inside that we have the alkalytics files and also we have the requirement txt and the demo files okay uh now uh first you have to clone our repo you can just clone our repo and once you clone our repo you are going to get this that license plate detection using YOLO V8 you will get it here next you have to go to the folder so you just do CD and the name of the folder in this way so similar the nothing you have to change you will get into this folder uh still now we haven't downloaded a data set it's very important next is here we are going to download a data set this is the important part and here you have to paste that link if you remember this whole code you have to paste here now this code will not run because I have removed my API key you just take the code from here and you paste it here if you are using some other data set paste that code here and you just run it and it's going to install robofo for you and as well as it is going to download a data set for you okay put in few minutes so depending on the size of a data set it's going to do that so it will download the whole data set for you so once you run this thing so I'm not doing it because this all the process it takes some time to download data set and all that so I have already did it but in your case you have to do it all the things you have to do it and then what will happen you are going to get this license plate detector file okay and inside that if I just show you you are going to get like I said test strain valid okay uh this strain valid so inside test you have to test images inside when you have to train images and also labels not only images images and levels and inside valid you have the valid images and the levels okay that's all you are going to have and also there is a data dot yaml file this file is important this is one file that you have to change and I'll show you what things you have to change in the file okay so once you download the data set you will have something like this so let it be here next you have to install the libraries required Library so here we have a requirement.txt file so if I just show you in the requirement.txt file I'll just put it here requirement.txt file we have everything here and all the versions We have mentioned so Alternatives 8.0.3 uh why I have mentioned the version is because in sometimes like if you change the version little bit you'll have a lot of issue so all the versions are mentioned and based on that it is going to download the libraries so you just have to run this code that pip install requirement.txt and it is going to download all the libraries for you you don't need to do anything okay so at this point you have downloaded all the libraries you have downloaded the data set uh you had you have downloaded a data set an alternatex file you already have okay here we have the alternatex files okay so now we are actually ready to train our model now before we train the model so this is the command that is going to train our model so let's look into it what we are doing here we are firstly we are using python to run the file next is here we have to keep the frame dot Pi file uh location so where is the train dot Pi if I just show you where is the train dot Pi is uh just give me a moment I'll just put this thing here uh train dot Pi if you see uh here is it a uh so you have to go to ultralytics and from Ultra editix you are going to have the Yolo from there you are going to have the version 8 inside that you have detect inside that you have frame dot Pi also pretty dot Pi so here you have the files so here we have just wrote the whole path contain and add that at that and frame dot Pi so frame dot Pi is the file which is going to train your model next is which is the base model we are using we are using YOLO 8 and YOLO V version 8N dot PT this is the base model you are using now there are separate model also YOLO version 8X YOLO version 8 different models are there so if you want to use them you can use if you know yellow uh you should know there are several models there I'm going to use 8 and 18 will be fine for me for in this case but yellow 8X also you can use up to you obviously okay next is we have to give the link of the data now how to link the how to keep link of the data we just have to give it the link of a data.yml file okay now here you need you may have to change the data set path so I'll show you what you have to do let me remove the whole path now data equal to there is no part given what you have to do is you have to go to your data set open it find the data.yml file copy the path and here you just paste it in the data okay you just paste it here and the space okay so now you have the data.yml file uh let me create my file uh path and finally mentioned the number of epochs here for this demo I have put it 100 based on your requirement you can just put it and also you have to check the data and all the things based on that you can choose the book okay for now I have put it just 100 only now one thing you have to change what is so once you open now once you open your data.yaml your data dot EML is going to look like this so I'll just show you I have modified you already but I'll show you how it will look like in your case so in your case it is going to look like this your data.aml file so here at the very end you have the train and validation uh fold train and validation folder uh path and the path is based on that it's going to give you the name of the main folder which is license plate detector 1 so the name of the folder of the data set and then train and images and valid and images but in our Google cool app uh we also have a we also have a path like the whole data set is inside this license plate detection this folder and this folder is also inside the contain folder if you know Google collab all the things are inside the content folder so this if you run this thing it is going to give you error that hey I cannot find this files because it will try to search these files in from the source okay so so that's why you have to change this parts and how you can change very simple you just have to copy your main uh this main folder path you just have to copy that okay and then you have to or or one thing another thing you can do instead of doing that what it will be easier for you is so this is train and validation you come to your you come in come inside this uh data set folder you copy the train path you put it here you are done oh no not the train but sorry not a train but you have to give the image path inside frame you have to get the image path so copy the image part inside frame and okay this is a problem we get multiple times sometimes here it's hard to get it just give me a moment so yeah here in the train what you have to do is you have to copy the images folder path of the image folder and you have to put it here similarly for the validation you have to copy the valid and images folder you copy the path of the images folder and you put it here that is the only change you have to do okay this is the only change you have to do and then you have to control s so you save it any button next you can run this file okay and once you've done this file it's going to take some time so in my case it took 20 minutes because my data set is small based on your data set and number of epochs it will take some time but at this Google collab and the GPU is like very powerful it will not take a lot of time okay compared to your machine I don't know if you have a powerful machine different case but in most of the times we don't have very powerful machines in our homes are not very powerful gpus at least so in that case Google collab will be faster so and after uh it will be done training one thing is very important at the very last line is going to say Laser Save to run slash detect slash train this folder is very important so basically it's saying that all the trained model has been saved in the runs folder inside the detect folder inside that frame folder inside train folder you are going to get all the things so you are going to get the result.png which is uh so as you can see the graphs and all the things you will get but the thing which you can check to make sure that yes if it's working or not so grab Source you can check but if you don't have a lot of idea about graphs you just check the prediction results so Val batch to prep okay so as you can see here so basically this is the Val batch 2 dot bread and as you can see all the numbers so in the prediction it is actually detected all the number placed correctly so that means your model is getting trained well okay because as you know the validation images are completely different but in validation images also it is doing the prediction quite well so that means the training is going well and it has Trend and also if you check the Val batch one thread so that also you can check just give it some time so as you can see batch one also the result is pretty good so that means that model A has been trained so here now where you will get the model so the model you will get in the inside the weights you are going to have base.ptlers.pt now use the base.pt so that is your final model and also this base dot PTI already are uploaded in GitHub so you can check it out but it's not I would not say it's the best model because obviously the number of images we have used is very less and number of epochs is also not that high and also the model is very small inside so it's just six MBS I guess so it's very small model but still the model works and I'll show you how how good the model Works actually so from here you are going to get the model so remember where your base dot PT is getting saved and you just copy the part of your uh your model you can also download it from here just download okay next solar model has been trained we have checked our prediction on the validation data so you know like it's working but next we have to check uh with a video or an image that how really good it is working so for that I already have attached uh attach a demo dot MP4 and demo2.jpg so I'll show you how actually these two files actually look like so I'll just check show you from here so if I just reveal them in finder so demo2.jpg this is one demo image I'm using randomly downloaded from Google and this is also one I want to show you first this is also one basically card video I found some some other videos so yeah so I'll show you let's see this is basically uh the number plates here okay so uh these are the raw files now we can actually run our model on those files so what you can really do is uh here is the code so this is the code to check with the video that demo.mp4 so python the first thing is you have to give the predict.pi path now predict dot by path will be the same path there'll be no change okay at this page dot Pi you can find in the similar place where we found that plane dot Pi next thing is we have to give our model path and model part if you remember that base dot PT we have just copied so what you will do is you will come here and you are going to just paste the whatever the location is we have just copied so let me just let me just paste it so here we are going to paste our path which I have pasted the path and finally you have the you can paste the uh demo you can paste the video file video your video path or image path whatever you have so in my case it's a video and then so here I am going to again run the same run the model actually on it and I'll show you how that is actually look like so here it is using the biz.pt and here it is going to check frame by frame the whole video and it's going to save the video here and from there we'll download the video and I'll show you how the resolution looks like okay this is a very small video so 631 frames there so let's see let me just take few seconds and here we go almost done and here we are done and if you see here where the result has been saved two runs detect print seven so you come to runs detect plane 7. okay here you get a demo.n before let's just actually download the file it's very small file will not take a lot of time so it's downloading so in the meantime is download I'll also show you for the image so similar thing all everything's uh similar just instead of the video the image and I'll run it so here we are here we are done our video is also downloaded I'll show you an image is also done so any save and train 8 so let's just check train it so let's check the image first and then I'll show you the video so train it we have the image let me open it for you and as you can see it has written properly now come to the video so as you can see in the video also it is detecting the number plates Y to L as you can see okay as you can see it's 3D numbers quite well now also one thing we can do we can actually check another random image from Google so you can just go to Google we can search for number plates number plate car something like this you can search we can go to image I don't want to take this kind of images a little bit bigger where I have the whole car maybe something like this this not yeah maybe this is this is one we have the car little bit so I'll just save the image uh save image I'll just give it a name let's say a number license plate LP maybe short name next what I'll do is I'll just upload the image so in my downloads I have the image LP so I'll upload the image in this folder it will take few seconds LP has been uploaded now we will just say LP just a minute LP dot JPEG and just run it and see if it's working on a random image from Google when yeah it's done and if you're wondering why it's taking so much time for our image remember that is actually loading the model so it takes some time to load the model runs train 9 detect train nine and we have the lp.jpg and as you can see it has detected the number blade properly so this way it's working quite well okay with a very small number of uh images even I would say a very small number of images working quite well and a number of epochs are also not that high just 20 minutes of training and is working this good so basically from here we can actually prove that with a very less number of image and less number of epochs also you can actually make a good model okay with yolo version 8. now let's say you have to train a different model what things you have to change you already know but just a recap you just have to change that logo flow code so that instead of this data set you will download some other data set based on that and inside the data set you have to change the data.yml file you have to give the you have to give the parts of the test images and train images and then what you have to change is you have to change while training you have to change the while you are going to train you have to change the what is the training code you have to change the data set path only nothing else just the data set path and when you are going to test your model you are going to you have to change the uh your train model uh your train model part so if you see here so that base dot PT so you have to know where the base.pt is and you have to change this path and also the source based on what video or image you are using you have to change the source path also this is the only things you really need to change if you want to use the same model for a uh you have to if you have to use some other data set to train a new version if these things you only have to change nothing else okay and coming to if you have to make your own data set maybe there is something you want to track and that's not uh the data set is not anywhere in the internet in that case you have to make your own data set you have to bring the data you have to label it and you have to make a data set that thing we are going to cover in a separate video so very soon we are going to make this video so stay tuned for that one and I think that's uh that's it for this what's up the video and I think if you have any questions please let me know you check this model you check the whole code and you can try different images and different stuffs you let me know how the results are and if you have any queries you please let me know and all the materials I have used will be in the description the GitHub report uh link of the data set everything will be in the description so that's it so thank you everyone for watching this video and I hope you have learned something from the video so please hit the like button and also subscribe to channel so that we can make more contents like this and many more contents like this are actually coming very soon so see you in the very next video
Info
Channel: SPARKLERS : We Are The Makers
Views: 5,089
Rating: undefined out of 5
Keywords: YOLOv8, ObjectDetection, LicensePlateDetection, GoogleColab, CustomModelTraining, ComputerVision, MachineLearning, AITutorial, DeepLearning, DatasetAnnotation, DataAugmentation, ModelConfiguration, NeuralNetworks, ImageRecognition, TrafficMonitoring, SecurityApplications, RealTimeDetection, ConvolutionalNeuralNetworks, AI, ArtificialIntelligence, OpenCV, PythonProgramming, TensorFlow, PyTorch, DataScience.
Id: zh1CZK7chbo
Channel Id: undefined
Length: 29min 17sec (1757 seconds)
Published: Mon Sep 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.