How To Train Custom Dataset Using Yolov5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey how's it going everyone so uh in this video i'm going to do a very simple uh and easy tutorial uh that shows how to um how to run this model and how to train any of your custom data sets so the first thing we need to do is to open up a such a google collab notebook and then we need to clone the yolo v5 github page and we can do that by hitting this start button and it's going to be cloning uh all of the yoda v5 files for us so once the cloning is complete it's going to print out this setup complete message and the next thing we're going to do is to manually import some of the folders that's going to that's going to contain all of our images and annotations so we can do that by creating three set three separate folders and the first folder is train and the second folder is to be valid and the third folder is going to be test and we're going to be using these three folders in our training so and now we can so inside each folder we can basically create create another folder another two folder so new folder inside valid so this one is gonna be images that's gonna that's gonna contain out of our image files and another folder so this one is going to be i'll call it labels so this one this one is going to contain out of our annotations to the corresponding images so we'll do the same thing for the rest of the two folders so create new folder images new folders labels and tests with the same so all right so now we have uh all of the folders created so the next thing we're going to do is to manually import some of the pictures or some of the annotations to these three folders and we can do that by so for example i'm going to be using these data so i'm going to drag and drop some of the pictures inside this these folders so uh for example so i will drag and drop five pictures into each of the folder so for example i'll select the first five pictures inside this data set and drag it to the test folder so images and you're going to select okay since uh once you're out of the session all of your data is going to be deleted all right so that's out of your images there so and you need to uh you need to upload the corresponding annotations so these are the the first five annotations so you need to drag and drop here all right so we can do the same thing for the rest of the two folders and now we can select uh the second five pictures and we can basically uh oops sorry drag a drop to the train folder and labels and obviously we're going to be using much more pictures in our actual training so the reason i only selected to like five pictures is only for demonstration purposes so we're gonna do this for labels okay now uh each of each of these three folders contain some pictures and some annotations and now we can begin our training process let's just confirm that everything is correct yep and in order to do so we need to also manually import a uh or you should create yourself a very simple uh yml file so inside this ymf file that's gonna contain all of your uh the location to your training folder and the location the location to your validation folder and the unsave over here basically stands for the number of classes so in our likely intelligence case we have active sales and dormant cells so that's going to give us two classes and the number so the names here stands for uh the the name for each class for example zero over here stands for active and one over here stands for dormant so we need to um also upload this yml file to our so we can just drop the yml to our root folder here which is um i think it's content so if you have any question regarding how to create a yml file for your training model so please let me know and i can answer your questions and now we what we need to do is to visualize uh just to just to confirm uh we we we actually uh have our uh yml file uh we need to try to visualize it so what we can do is do so let's first check what is our occurring uh what what what is our current working directory and we can do that by uh by printing a pwd so our current working directory is inside i don't know why there are so many euro v5 but we're currently inside the euro v5 folder and there's another util v5 oh what is happening oh i cloned it i i cloned you know v5 uh photo twice but uh that doesn't matter so we can go back so so we have to change our current working directory all the way back to content since we stored our data dot yml here so we can do so by uh by typing cd uh dot dot so that's gonna go to uh the previous directory now we can do this again and again so now we're inside this uh root folder over here and then we can visualize our uh data.ml so yeah it looks pretty good and then we can um we can import this uh we can import the yml and define a number of classes based on the yaml so basically we're importing this into our model so all right so this is complete and now we can go to um and now we can visualize we can try to visualize our model configurations by uh going to so we so specifically over here we're going to be using uw v5s since s stands for small data sets we don't want our training time to be like extremely long so that's why i kind of choose this you to v5s so we can try to visualize as you can see we have a bunch of anchor and backbone and these are basically our neural net here and and we can customize the i python write files so we can also write some of the variables so we can basically run this and we need to uh write uh the uh yoda v5s uh yml file too so we're gonna basically click that and now we can begin our training process so basically uh all you need to do is to to click the run button here so click this and another another uh friendly note is that uh if you if your model involves a lot of the a huge uh data set of images and annotations you need to make sure that uh you install uh you you kind of import a automatic automatic automatic um uh clicking code to your um console here so basically uh you can use this function so what this function does is uh it's gonna click reconnect button so basically uh so basically it will uh keep your uh it will keep your model training from disconnecting so basically you can what you can do is you can open up your uh your inspect and you can copy and paste the the code here and run it so and yeah let's just wait for this 50 epics to finish yes since we're only using the extremely small amount of data set we can it makes sense that the mean average precision is zero but if you use like a relatively reasonable data set it's not going to be zero it's going to be starting from a very strong small number and it's going to be going up very gradually so now so yeah so so uh what that javascript code is gonna do for you it's gonna so is that every minute it's gonna click that uh reconnect button and you're gonna be prompted with uh this window so this will be a reminder that uh some some some like automatic code is doing uh active clicking for you now we have our model ready so and to visualize uh the mean average precision which is an important parameter to measure the accuracy of your model so we can visualize our tensorboard so it basically tells you how uh some of the so it basically shows you some of the diagrams so for example this mean average precision and and recall rate and loss and so on so you can see uh the mean precision is actually zero because we only included five images for each of the folder which makes sense and after that you can so you can basically ignore this yeah so what this does is the this is going to display the ground truth data for you and and what this is going to do for you is going to print out an augmented training example but uh our emphasis should be on uh train uh like running the model uh so running our model on a video so let's just like visualize our run result so we have a best so bass pd is uh is the model with the best uh mean average precision and last up pd pt is uh your last epic the mean i've mean the mean average precision for your last epic of training and so and to test your um your model only video you can basically uh drag and drop a video to your uh so for example if you want to like use this video you can basically drag and drop uh this video to here but i'm gonna i'm not gonna do it because it's super uh simple and easy to do and after you have done that you can basically uh execute this comment so we're just gonna be which is gonna generate uh frame to frame uh some of the uh they uh so some of the inferences for you so and yeah so that's about the core of this video just to show you guys how to like import some of your custom data sets to this this uh yolo file and then uh how to use uh the generated uh the generated model oh yeah before i before i uh in this video i want to show you guys how to how to actually save the model you've trained so to save uh the model you've trained you need to execute this which is gonna mount uh so now so basically it's going to tell me some authorization code i'll just type it here okay so we're going to mount the content to our google drive and then you can basically save uh so copy your it this this can either be best dot pd or last.last.pd depends on which model you want to use but i typically use last.pd and basically you can copy this uh okay so it looks like euro v5 runs wait oh so sorry this is supposed to be experiment zero since like i did two experiments in my last round so that's why yeah i forgot to change it so now so it's going to be saving this model to your google drive and you can confirm that by going actually going into your google drive and check it so it should be located in your google drive somewhere yeah as you can see it's right here so okay so that's about the end of the video i hope you i hope this video makes things much easier for you and please let me know if you have any question thank you so much have a great day and
Info
Channel: KUNLUN WANG
Views: 2,462
Rating: undefined out of 5
Keywords:
Id: aEh-P4lUWFA
Channel Id: undefined
Length: 18min 45sec (1125 seconds)
Published: Tue Oct 06 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.