YOLOV9 Training on Custom Dataset with Google Colab | Object Detection Using YOLOv9

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial I will teach you how  to train y v9 model using your custom   data set I'll also teach you the  tips and tricks you need so that   you don't run into any form of error  at all ready to do it let's get into it all righty guys so start off by looking at the  folder structure you need in order to train your   custom YOLO v9 model the folder structure follows  um the Yol V8 folder structure so on my desktop I   have my root folder and inside this root folder  we have three sub folders and this is kind of   like the YOLO V8 folder structure so you have test  and inside test you have images and labels then   inside your train the same thing you have images  and labels as well and the same thing applies to   the validation as well so all you need to know is  that you have a root folder like this and inside   this root folder you have your test train and  validation data set and inside each of them you   have your images and they are corresponding labels  okay so all you need to change here in order not   to run into future errors is your data. yl file so  when you open it you can see by default this works   for ULU V8 you have your train the path showing  to your train to your images validation to your   images but with this one it won't work like this  you run into an error when leave it like this you   get the data set not found error so in order to  avoid that error you need to structure it in this   way whereby you use the name of the root folder in  front of the path leading to your images so when   you change everything like this there's not going  to be any error so all you need to do is to use   the name of your root folder in front of this and  you remove those two dots and this will solve the   data set notfound error so after this modification  the next step is to upload this data onto your   Google Drive so right from your desktop all you  need to do is to drag and drop this into your   Google Drive so you just drag and drop it like  this and that's all it will take some time and it   will be uploaded and you can access this in your  Google collab notebook but I've already uploaded   this data and right here you can see it when I  open it it's the same structure we have valid   train and test so the next thing is that I've uh  prepared a Google collab notebook that you guys   can just follow by just clicking and changing  your path to your data and with that you'll be   able to train your custom YOLO v9 model so right  at the top we go through some steps first you have   to Mount Your Google Drive that's if you'll be  using the data from your Google Drive then the   next thing is to clone the Yol v9 repository The  Next Step you have to download the data set for   training if you'll be using roof flow so for that  you just need to download the data from roof flow   and this the data set we be using I said earlier  we are going to be detecting guns so in order to   get the data from Robo flu you just have to click  on download data set and make sure the show code   button radio button is checked then you continue  with this after zip to provide you this code   all you are interested is copying this code and  pasting in your Google so you just have to copy   it and paste it in your Google collab and that's  what I've done right here in this lines of code   so after doing that you'll be able to download  the data set after that we go ahead and download   our weight for training the model and as at now  four weights has been released for y v9 already   so you can use either of them to train your model  but we will be using the gilan architecture so   we using this first one but you can go ahead  and download all of them and use any one you   prefer after that we will train our model just by  running this line of code then we can visualize   some of the results and we run inference on our  validation images okay so first things first we   go ahead and change your run time so that you can  utilize the GPU so you go to change run time and   you change it to D4 GPU which I've done it already  so you can see it is check here that I'm using T4   GPU after this if you'll be using the data since  I will not be I'll be using the data right from   your Robo flow so I'll just ignore mounting my  drive but if it's your own data and it's not   Robo flow just Mount the drive and it will appear  here and you make sure you just copy the path to   your data set and you replace it right here okay  so go ahead and clone the Yol v9 repository and   this will appear right here so it doesn't only  clone it to clone it and change directory into   that folder install all the requirements then  also go ahead and install roof flow since our   data set is coming from roof flow okay so we are  done with this cell and if we refresh here you   can see the Y v9 folder and inside here we have  all the required files the next thing to download   the data set so you just have to run this cell and  this will go ahead and download the data set for   you so it has downloaded the data set and also  extracted it and it will be in that same folder   you v9 so right here you can see our data set but  remember what you have done by just changing this   particular uh path we have to do the same thing  right after downloading the data from roof flow   so we have to open the data. yl file and then we  have to change it from this to this and then all   you have to do is to save it by pressing contr  s to save it and that's all you need to do so we   can close it up can also close this app to keep  things clean then move down and then just click   this cell to download the WID so guys all you  need is to be running the cell and also follow   the exact same step I've followed then the final  part here is to train this model so to train the   model make sure the path is leading to where your  folder is so you go to where you've downloaded the   data and copy the path to the datl file so copy  path and make sure you change this right here so   doing that will just save you from a lot of errors  but if you using your um Google Drive then when   after mounting it you make sure you copy the path  to the data and replace it right here after all   this out of the way you just have to run this cell  to kick off your training but before you train if   you are using CPU then make sure you change this  zero right here to CPU other than that then it   should be zero and this will grab your first GPU  available for you and in our case is the T for GPU   so I'll go ahead and run this C right now and our  training process should begin if everything works   well so you can see it has loaded the images from  their corresponding folders and uh our training   process has begun so we are training for only 20  EPO because this is a tutorial and I don't want   it to take a longer time so this will train for  20 EPO and after that we go ahead and show the   result but in your case you have to increase the  number of epo normally my rule of thumb is that   I put it at Thousand because I know automatically  you V8 YOLO v9 and all other YOLO models when you   are trading them they have early stopping which  kicks in if uh the performance is not improving   over time so that saves you resource and ton  of time so yes have to put a higher number   there but in your in our case here I'll just  put 20 so that it will train fast and we will   see the results all we care about is the process  working and to be able to train uh our own custom model so guys this will taking some time so  I'll see you right after the training process   and then we run inference and also test uh  the results all right so the whole training   process is done and you can see the result is  saved in run Tren and ESP folder so I'll open   the y9 folder and we locate runs and then uh  we have train and ESP folder so over here our   result is saved so you can get the F1 curve let  me open this up you can get our width which will   be right here okay so in order to visualize  some of this result first we visualize the   labels so you just have to copy that path down  here which is labels.png so right here and then   you have to uh replace it here in order to  see some of your result then I will run this cell and you can see some of our  performance this doesn't look great actually because we've trained for only 20 EPS we also  continue to check for our confusion Matrix so   let's try and locate the confusion Matrix Path  so this is the path you just copy the PA and   make sure you replace it right here to see your  confusion Matrix so I run this cell as well and   this will show us our confusion Matrix for our  training so you can see how our performance goes   right from here so every result you need is  provided here and you can just access all of   them and see your training performance so we  can also check our batch uh validation image   so let's try and locate that so I think here is  it validation batch I'll copy the path and put it   right here and I can go ahead and run it so this  is the performance on some of the images it's not   detecting gr so I think the 20o is not enough and  in reality that's not enough to train any model   at all but because of this tutorial I just want  everything to move fast so that you guys will see   the whole process in training your custom yo v9  model okay so the next step is to run inference   on some of these images and for that we need to  locate our weight so for our weight it will be in   a weight folder and then you have the best and  the last PT so these are two instance of your   width but always use your best. PTU because it's  the best performing model so just copy the path   and make sure you replace it right here so this  will also load your validation images so let's   go and locate our validation images so that we  can validate our weight so all we need to do is   to locate this validation images and that will  be right here valid and I think we'll have to go   with this folder so all we do is to copy the path  right here and replace this here with that exact   path then I think we can go ahead and run this and  see how it performs okay so this will also run and   then save the result into run DET and uh esp2 so  it's still in that same R folder so let's locate   it and see how it has dictated some of these  images so where is dictate okay it's right here   then here it is so this is how it perform on some  of the images I'll just load them right here you   can see it's not looking great at all because  we've trained for only 20 box this is also not   looking good this this is not detected at all  so um overall we are able to train our model and   we are not getting great performance because we  train for only 20 epops so guys this is the whole   process of training your model if you want to  train your model just follow the exact same step   I'll share the notebook in the video description  so you can just download it and use it for   yourself and also if you have any questions let me  know in the comment section you can download this   model and use it later on for yourself so this is  all for this tutorial if you love it make sure you   give me a thumbs sub and also subscribe thank you  for watching and I'll see you in the next tutorial
Info
Channel: Tech Watt
Views: 865
Rating: undefined out of 5
Keywords: yolov8, segmentation, image segmentation, object detection, ai, machine learning, deep learning, pytorch, python, pytorch tutorial, computer vision, data science, pandas, programming, image processing, data processing, license plate detection, number plate detection, car detection, vehicle detection, yolov9, yolov9 on custom dataset, YOLOv9 custom model
Id: Opr53ctUVlA
Channel Id: undefined
Length: 13min 4sec (784 seconds)
Published: Mon Feb 26 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.