YOLOv4 in the CLOUD: Build and Train Custom Object Detector (FREE GPU)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what is going on everyone in today's video I will be showing you how to train your own goal ovie for state of the art custom object detector in the cloud all for free I'll be walking you through how I created a custom object detector for license plates but you can create a custom object detector for whatever your heart desires I'll be showing you guys how to gather your own custom data sets with ease super super fast I'll also be showing you guys how to customize configuration files necessary to do this custom training and I'll even show you guys how to test your custom object detector and see the accuracy of it in real time if you enjoy this video please don't forget to smash that like button and subscribe to the channel to keep up to date with all my latest yolo' before videos it means a lot to me and it helps grow my channel let's jump right into the video [Music] so in order to follow along properly with this tutorial you're going to want to go ahead and click the link in the description of the video to the Google collab and when you open it it's gonna look exactly like this and all you have to do is go ahead and click this copy to drive button right at the top and you're gonna go ahead and click copy to drive and what that's gonna do is save a copy that you can actually run of this club notebook in your own Google Drive so if you don't have a Google Drive account I recommend quickly setting one up it only takes a couple minutes and then you're good to go awesome so now once you have your own Google Cloud notebook open it comes the fun part where we can start to train our own custom object detector if you were familiar with my last video I went over how to run a out-of-the-box free trained Yolo v4 object detector with darknet in the cloud using Google Cloud and I've left that those cells and all those commands in here so all of this part all the way down to how to train your own you go looking for custom object detector is from the previous video so if you haven't already checked out that I recommend checking it out I'll link it up above and in the description below so check it out and it'll show you a lot of cool commands and way to customize your Yolo v4 outputs how to save the bounding boxes how to save to tech txt file and all that cool stuff and that you can actually use all those commands with your custom object detector after we've trained it so once you open up your club notebook you're gonna want to enable GPU so that you can accelerate the training and make it a hundred times faster than without GPU so you're gonna want to go ahead and follow that step to do that right here and then first things first you need to go to run time and run all and what's that that's gonna do is it's gonna go ahead and download the repository with the code as well as building darknet so we can start to train our custom object detector so it's just going to go ahead and do all the pre configurations for you and you don't do anything you can just check that it's working by seeing that the cells have started to run and there's sell that it says cert error or cert failure and it's gonna stop it there so that we can hop in and start to train our own custom object detector for the sake of this video I'm going to be training a license plate object detector to detect license plates on the back and front cars of vehicles so we can see that it's going ahead and building darknet which is perfect and we're gonna go ahead and let that round and I'll come back once it's done all the three configurations so if all went according to plan and hopefully it did you should see that in Step five running your detection with dark net and Yola before we can successfully see that dark net has been built by the fact that it is doing a detection on the pre-trained out-of-the-box model and you can see that it is indeed working it's detected the object within the image and it's stopped on the cell which we wanted it to do so now you can actually go ahead and you're going to want to do the next step which is actually just connecting your Google Drive to yeah your collab notebook so that throughout the entire tutorial you can use files for and save files to your drive so that anything happens during your custom training you have the files the Train partially trained or fully trained model files saved to your Google Drive otherwise you'll lose them if your cloud shuts down or suffer some reason you get disconnected so you're going to want to go ahead to this method to a Google Drive and we're gonna go ahead and mount your Google Drive into the notebook which allows us to access it so you're going to go ahead and click the link that pops up choose your account go ahead and accept the terms and then just copy the key that gives you head back to the notebook and paste it in and then you should have your Google Drive mounted now in your notebook and have access to all the files within your Google Drive so perfect and then I had the cell underneath this is just going to go ahead and shows me that it is indeed I can see all the files and folders and the home directory here of my Google Drive so it's working and that's all you need to do for these steps and then we're chewing a CD back in the darknet don't forget this cell otherwise you are gonna be in the wrong folder throughout the entire priority of this tutorial I've seen that in my previous videos where it says darknet is not a folder and that's because you didn't do the CD command so if that's ever the case and you see that error saying darknet is a folder not a file just do CD darknet right here so now that we have our Google Drive mounted into the collab workstation and we have access to our Google Drive you can now skip to the now custom object detection x' heading down to right here how to train your own Willoughby for custom object editor and now comes the super super fun part guys so you can create any custom object actor you want you don't have to follow along with me I'm gonna be doing a license plate detector so feel free to do so as well or do any single class or object that comes to mind and in order to create a custom object detector we need the following a labelled custom data set a custom duck config file object data and object of names files and train 60 and tests D if we're gonna be doing validation data set which we are I'm going to show you guys how to validate your model and show that it's accurate so we're gonna go ahead and do all these in this tutorial so first come to the gathering and labeling of your custom data set this is probably the most important step of the entire tutorial because without a good data set you are not gonna be able to have a good and accurate model it all comes down to the data I'm sure you've heard that Lots but it is true there's two ways that you can do gathering your custom data set you can do Google's open images which is a pre gathered data set that has over 600 classes and millions and millions of photos that are already labeled which is awesome and I'll use it for most of my videos it makes it super easy otherwise the second method is actually gave their gathering your own images either through google images or whatnot and labeling them manually which can be a very tedious task and I have videos on both of these two methods I'll pop them up above and in the description below so you should see like on screen if you want to choose and need more full tutorial and in-depth explanations of how to use these two methods so the data set open image is Google's data set you can go to it click the link explore and you can actually see that there is going to be hundreds and hundreds of classes and you can just explore this and really there's like hundreds you can see here endless opportunities so it probably seen us in previous video of mine and the one that I'm using the class that I'm using is vehicle registration plate a que license plate and I'm gonna be creating this custom object detector so it by the end of it should be able to properly classify license plates and detect them with images so a lot of cool applications with license plate so that's why I chose it and I know it's a beginner tutorial for a lot of people that in school is to do a license plate detector so hopefully this helps you up so we're gonna use for this tutorial a toolkit that I've used previously in my videos that allows you to easily extract the images from this open images data set and the labels and convert them into a Yolo v4 format perfect for training a custom object detector so I have a previous video where I showed on you live of Yolo v3 the format for the labels and images is the exact same formula before so this toolkit and that video is still extremely relevant and there's no changes to it so if you want to check that video out again I'll link it up above and in below in the description and you can clone my repository for that the AI guys code Oh idv for tool kit you just go ahead and clone this or download it whatever you want and it's gonna have bald and it's this necessary files and steps for you so here are the commands I'm using so we're gonna create first a training data set and then a validation data set that will be used for testing our model and showing that it is highly accurate so this is my command I'm going to be running to gather my data set I've already gathered my data set so I'm just gonna do a tester command here for you where I'm gonna change the limit to 15 so it's gonna got 15 images in my full data set that I actually used for training it's 1,500 so the more images the better I usually say but you don't wanna go overkill and do thousands and thousands for a single class I'm only doing a single class object detector here you can actually do multiple classes just having them multiple classes if you check my video it shows you how and you add the flag multi classes one and it will download all the classes of images into one file for you and that's what you're gonna want to do like I said check out my previous video if you're doing it from multiple classes and it's pretty straightforward so we're gonna go ahead and run this command and it's gonna go ahead and download 15 images ooh here we go this is means it's puppet properly working if you can see the oil before downloader it's gonna go ahead and download 15 images as my training data set but like I said I've actually done 1500 for my actual detector so it's downloading the 15 images and then after that we're gonna do the same thing but for validation data set so for type CSV and the first one it's trained for training images so the actual open images data set has certain images it keeps for training and validation which is perfect for us the training data set is or type is always the larger data set so I think this one has thousands and thousands of images for license plates I'm only taking 1,500 and for validation I took 300 it's recommended that you take anywhere between 20 to 30 percent of your training data set size and use that as your validation data set size that's pretty common in artificial intelligence and machine learning in general so that's what I did 1,500 for my training data set 300 images for my validation so let's see if it's perfect if it's got my training data set yep it has and we're gonna run the same command but I'm trying to show you as an example my limit set to three into the 300 so it doesn't take a long time because downloading fifteen hundred or three hundred images can take a while so don't be alarmed if it takes a couple minutes several minutes to download all the images and then I'm gonna go into where I cloned my repository so you're gonna go this is the root folder boid data set and you're gonna see that I have a train and validation so my training has my images with my license plates and the same for validation it will also have it has three images and the labels straight the toolkit raw doesn't have the labels in the proper UOP format so that's why I added to this toolkit is convert annotations that goes and actually transfers all the annotations and to a proper you'll be for format for you so the next step once you have the images you're going to want to check this out and it's going to convert them into the proper labels so what you do is the classes txt and the root folder right here you're gonna want to go ahead and open it up and once per line whatever classes you have for your detector you're gonna want to go ahead and put them one for line so I only have one class vehicle registration plate but let's say I had elephant I would put elephant on the second line if I had giraffe I would do giraffe on the third line so one class per line and however many classes you have decided to kill your detector for that's what you're gonna want to do so I'm gonna go ahead and delete not gonna save it so I showed you here for motor classes this is what it should look like and so I have vehicle registration plate and now I can go ahead and actually run the Python convert annotation script which goes ahead and does it for you it actually converts all of the labels into you all before good work there we go so once you have your classes dot txt saved you're gonna have let's just show you that it's gone through both directories when you run the command for convert it's done my train and my validation so now if we go back to our datasets and we look in the Train it has should have a text file for each image and that's the proud before format and if you check it should have the class this would be the class number of what line it's on starting at zero in that classes txt so all mine should be zero because only have one class so this represents that it's license plate and this is the coordinates so that's the proper format and then once you have the proper format you can run this these two lines to go ahead and delete those old labels so you can either run the command or you can just go in here manually and delete the old labels because we don't want them in our datasets anymore so I'm just gonna show you guys how to manually do it just go in right-click and delete both so you can do that or like I said you can just run these commands within the powershell so now that you have our datasets properly formatted in the you'll be for format we are good to go and that's our datasets but first you're actually going to want to go once you're done this this is the second way method to where i manually set it I'm not gonna go over that once again there's a video on that that I have on my channel so check it out if you're gonna manually label your datasets because it might you don't have the classes you want in the open images I recommend checking open images first if you don't have it then resort to manually because it does take a heck of a lot more time so now that we want to move our datasets into our cloud VM so we can access it while training look in here so we're gonna okay so what we have to do is we go into back into our datasets you're gonna want to rename your training data set so right click on your training data set folder rename and call this table for object that's gonna be your training data set and then we go to validation and you're gonna rename this one test that's gonna be our test data set so once you've done this you're gonna go ahead and zip both of them so compress them so that you can upload it to your Google Drive and it doesn't take gigabytes and gigabytes so just go send to I'll show you that again right click and go send to compressed zipped folder and there we go we now have our object zip and we'll do this you do the same for validation right-click on it send to compressed zipped folder and it's gonna compress all the images and then you just go to your Google Drive I recommend a yo lo v 4 folder for all of these files and if you want to see what I have in my files I will actually have it uploaded to my repository for Yoli for cloud tutorial and I'll actually upload all of my files here not my training files because I mean my datasets because there are hundreds of megabytes but all the configuration files that you'll see you later on are here so if you get stuck you can check mine but yeah so you're going to zip them up and then you're just going to go ahead and drag them just click it and drag it into here I've already gone ahead and done that you can see I have my object unzip and my test does it of my 1,500 images and my 300 images so we're good to go we've moved it over to our cloud VM and then are we moving into our club beyond the movie our Google Drive and now you just go ahead and run these commands and they're gonna actually copy your object unzip and test up zip into your collab workspace your VM and then you're gonna unzip them so that they are not compressed and now they're at full size within your cloud VM so you can access them for training so we've gone ahead and done that and as you can see it's unzipping and inflating all of our training images and our validation images so that's perfect and now for step three its configuring all of those files that I just showed you in my repository generate object object config for our custom training so you're gonna run this command download the config file it's going to download the out-of-the-box config for Yolo before and rename it as you'll before object config in your Google Drive so now I can see it it's saved to my Google Drive yellow before object config and this is going to be where you configure all the parameters for your custom object detector there's quite a few parameters you need to configure if you're doing it along the local machine you can just run this command to download the file but now comes time so this is where a lot of people make mistakes and they make typos if you make a typo here it is going to affect your training it might not work so you're gonna go ahead and carefully use all these equations that I've set out for what you should be having in your dot config file for your custom object detector it changes depending on the number of classes you have and just also just kind of what kind of accuracy you're looking for there are certain things you can tweak to make it more accurate or less accurate and speed up training so you're gonna want to check this out very thoroughly but I'm gonna go ahead and show you mine so you're just gonna go ahead back to your Google Drive wherever you just save the dot config and you're just going to double click on it actually and then go open with and you should have a text editor you can just use the text editor within Google Drive it works perfectly so here we go so you're gonna want to have batcher set to 64 and subdivisions to 16 that is what it is for training for just running your detector you'll see you later that you're gonna run on the testing for batch equals one and subdivisions equals one but for training you want the batch 64 and subdivision 16 for myself I like to have my width as four sixteen by four sixteen that's what I kind of seen a standard if you play with this width and actually increase it up here at object detector but it takes a lot longer to train so I find four sixteen kind of the optimal if you're running into issues and it's not as accurate as you want this is one of the things you can tweak by upping it by factors of thirty two it has to be a factor of 32 but as you saw it was 608 before you can have six eight by six to eight channels equals three that's for all your images are RB RGB but if your images are grayscale you might try changing this to channels equals two to one the next thing you're gonna want to Train change for your parameters is your max batches so your max batches you'll see I have the calculations here it should be set to number of classes times two thousand so which I'm training for three classes six thousand I'm trading for five classes it's time thousand but but you can't be less than six thousand so if you're training for one class two classes or three classes this will all be set to six thousand just to allow enough training iterations to get an accurate model so I'm only training one class but like I said the minimum can be six thousand so I'm gonna put six thousand and then you're gonna change your steps the two step values should be 80% of the max batches and 90 percent of the max batches so if I go back and see here my eight percent is forty eight hundred and my 90 percent is fifty four hundred so like I said I'm gonna set this to forty eight hundred that's 80 percent of my six thousand and ninety percent is fifty four hundred so steps is now changed that's perfect and now comes one of the trickier ones to do you're gonna want to just control f and look for classes within here so you're gonna get classes and you're going to change this to them or classes you have I'm training for one and then here is the trickiest change to make filters and convolutional layer above the yellow layer where you just change classes so you change classes in the yellow layer and in the convolutional layer directly above it you're gonna change the filters value filters value should be changed to this equation right here filters equals the number of classes plus five times three so for my one class it's number of classes is one plus five to six times three is eighteen but if you're doing four classes going to be 4 plus 5 9 times 3 27 and so on so make sure you do the math properly here and you can't just write number of classes plus 5 times 3 and your config file you have to make sure that you set it to the proper number so Martin I think I said is 18 and you're gonna do this for all three of the yellow layers and convolutional layer so you can see there finds classes three times within this file so you just going to search through go to each one classes equals one and filters and the layer above 18 so for the third one class is equals one and filter is equals and then you're gonna go ahead and just save the file and that should be it those are the changes you need to make so go over them again your changes you need to set batch equal 64 subdivisions equal 16 your max batches and your steps your width and height depending on the accuracy and how long you want training to take adjust those and then filters so there's kind of eight seven eight things that you need to change within this file and I also made a note here that if you're running into memory issues with your training and keeps closing your notebook or it keeps crashing one of the things you can change is an additional parameter in this config is where it says random so instead of random equals to one you can set random equals zero and that's going to go ahead and not allow for generating random equals one it will scale up your width and height depending by this factor that it generates so we could scale it up for larger images and lower for smaller images so it gives you a variance of what the image size is your model is better to seeing different sizes of images but by setting ran in equals zero it makes every single one set to 4:16 so nothing can get scaled up and cause for more memory to be taken it keeps it at the same level so I might be confusing but if you're getting crashes of your of your notebook and training isn't working that is something can change change that but now we have our custom config file and we're gonna go ahead and copy it back in to or notebook so we exported it as the old one made the changes and now you're gonna import it and upload it back into your notebook to use the second files that you need to change or your object unnamed and object data files you can see mine that I use within my repository right here right here so you can look at those and use them as a reference but I also show images here what you need to do your object that name is gonna be exact same as your class sixty you use for the toolkit so one class per line but here I've changed my vehicle registration plate is what it was called in the open images asset I've renamed it license plate so as long as you keep these in the same order as your classes dot txt you can rename them but they have to be in the same water because that's what the label will point to so the label will point to here and show the correct class name so license plate is what I'm calling my vehicle registration plate so secondly you're going to create your object data file this is the file that the training uses to point in the proper areas for all of the parameters it needs to the number of classes your training data set your validation data set your names files and where it's gonna save your weights files so the backup is one of the most important ones you're gonna want to set this into your Google Drive so earlier you created a link my drive so that's your Google Drive and then these is the file path to where you're stored so if I go to my drive and go back you can see that in my drive I the folder called EULA before and you're gonna want to go ahead and create this folder right here back up you can want to kick back up and in here is where all of your partial waits throughout training will get saved so if anything fluky food accident happens it crashes your notebook all the weights that you were saving let's say you train for three hours and wasn't finished they'll still be saved here so I cannot stress enough how important it is to use this back up as in to point to your Google Drive if you just pointed it to slash backup and not this first part it would just save in your cloud VM and if it crashed or something happen you wouldn't lose it and you would have to retrain from scratch so guys cannot stress enough the importance of that create a backup folder and point to it here in your Google Drive so we're gonna go ahead I've uploaded both of those files my object names and object data in to this you'll before folder I have right here do you guys really want to go ahead and create those and do the same just create them in text editor you can even do it within Google drive's text like I showed you we're customizing the duck config just open it up and do it there and then this is command just copies them back in to your folder so this is gonna go ahead and bring them back into the cloud VMT be used on the training copies the men and finally the last part of the configuration we need is generating this trained up tip ste and test.txt so you can access the scripts from the github repository you can see there right here these two scripts they are going to create the files that our training looks at for the image pots so trained up txt has all the image paths for all of the training images so it points to all of them and then test txt which will be created will do the same for all of your validation data set and it's just one of the things you'll will be for needs for the custom training so I'm gonna copy them both in I have them saved in this file or this folder and then I'm copying them in just to the repository I'm gonna run both let it run and that's gonna go ahead and generate your two txt files for trimming and testing and then we're gonna go ahead and verify it you wanna make sure that you created when you create about assets you called them object esthe or else this might not work these two scripts because I have hard-coded it for objective text and you can see we have test up txt and trained up txt if you run that command before they wouldn't have been there they just got generated and inside the contents of trained up txt should be like this and save validation but every test and it just shows you that has the path relative to where you are in your file structure to the images that you're gonna be training on and that's perfect and now you're gonna go ahead and final step before training download the pre-trained waits for the convolutional layers so you think of this as kind of doing some transfer learning almost so you're gonna take these base weights for all of the layers in the Yola be for architecture and you're going to start your training off of these optimal weights so if you didn't use these you would have to do it from scratch and learning a lot longer heck of a lot longer and it would not converge as fast so by using these as like a Kickstarter it allows your model to converge and be accurate much much faster so yeah we're gonna go ahead and use those to our advantage and you're AB you should as well so now comes the time that we have done all the pre steps pre configuration for training our custom object detector our license plate detector so now we can go ahead and actually run the commands to train so before we do it there's this one trick that I have that you can copy and paste this code in to the console of your Google Chrome it works on Google Chrome I'm not sure about edge or Firefox so you're gonna copy selection so by default Google collab has a thirty to sixty to ninety minute depending on where you are in the world time frame before it kicks you off and if you're training this custom object detector it could take several hours and you might not want to be at the computer you might want to go have lunch go to work and come back and still have it running but by default Google collab will kick you off after a certain amount of time of being idle like I said it varies so by doing this little hack in your console window it's gonna go ahead and make it who will collab believe that you're still there but simulating a click every couple minutes so it's just a hack I created to bypass the kicking law so we're gonna go inspect go to the console and just clear this and then you're just gonna paste it in the function that I just showed you so I just clicked it in here and click enter and that's gonna go ahead and simulate a click and that should keep your collab notebook open and running another thing you're gonna want to go to do is go to power settings power and sleep settings on your computer and change this to when plugged in auf never when plugged in turned off never and you're gonna want to do that because you're gonna plug in your laptop and have it run for several hours while you're training and if you don't have that your laptop like shut off or hibernate or go to sleep during your training and stop it and keep you off your Google Club you don't want that so just do that for the purposes of this video while you're training and then go back and change those settings back so now we have our detection or training cell you can just go ahead and make sure these points to your proper paths so you're going to want to do the darknet detector train object data config you'll be for AUB's and then the that that pre-trained waits on the convolutional lairs the flag don't show will suppress a image from showing up showing you how your model is doing that will will cause the notebook to crash because Google Club doesn't natively allow you to show images and then this dot map flag add delete this if you don't have validation data set this is just going to show on a chart as it shows iterations and loss it will also show you your mean average precision on the graph as well so we're gonna go ahead run that for some reason as well you get memory errors during your training you're gonna want to go ahead and uncomment this line right here and that will suppress this window or this cell from outputting anything does you'll see it outputs a lot so you're gonna want to go ahead and run this only if you run into errors of crashing during your training otherwise leave it because you want to be able to see your loss throughout so it's gonna go ahead and start training just like we want and I'll show you guys here this is the random coefficient I talked about earlier if you set to zero it won't do this but having it set to one allows you to scale up and down your width and height so we're going to see it now it's working its training this is what you should see and if I scroll up it shows the number of training iterations that's one it has a 1 and shows you the average loss on screen there so we can actually scroll down so this is number two training iteration two we set it to 6,000 so just imagine how long it might take it's at tier right now and the loss is super super high it's almost two thousand our loss but we want that to get down under five and ideally under two and even better would be under one for a very accurate model so this is going to train for probably an hour couple hours or two couple hours or more and you're gonna say this loss is slowly going down already it's gonna go down quite fast at the beginning and then start to slow down as the model takes longer and longer to train and get more accurate so I'm gonna let this train for you guys and then I'll come back and show you once it's done so I've gone ahead and I've actually stopped the execution of my training just because I wanted to go ahead and show you guys a couple of things that happened throughout the training process that you should be aware of so you can see I've stopped it out for about two hundred and twenty eight iterations and you can see that my average loss is already going down to under two from close to two thousand like it was and it still has about six hours left and trigger so that's crazy amount it's gone down a ton but it still has six hours left to get to that six thousand iterations and one thing to note is that the way the darknet annual before works is that every 100 iterations of your training and wherever you classify in your object of data folder or file as your backup it's gonna go ahead and save a weight folder and this is the file you use to run your object detection so every 100 iterations it'll save over the resave this file so this is the file that saves every hundred iterations and every thousand iterations it will save a brand-new weights file that will be you'll low fee for underscore 1000 for the 1000 iterations a new one for underscore 2000 and so on and then once it finishes it will have one called final dot weights so I wanted to point that out you can actually stop training halfway through or three-quarters of a three test out your different weights files see if you need to continue on and move on from there so after during training there's this chart PNG that gets saved in your route darknet directory right here chart PNG that shows how your model is doing so I'm gonna go ahead and open that up for you guys and as you can see I'm not anywhere close to being done my training cuz its she gonna show but as you can see this is where it's safe so this was saved at the 200 raishin mark so my loss was just above two it shows and it see how fast it's dropping so the model can actually get trained really quick and then around here it starts to level off and it'll start to just over fit at that point so if I actually look at the official Aleksey a B darknet repository the founder and creator of global before you'll see that this is what you're aiming to see by the end of your training so you shouldn't stop it early unless you're fairly certain that you are certain to overfit so I'm seeing that mines following this trajectory of quickly going down and then it's gonna study off and after 1000 iterations of training is when it starts to plot every 1000 iterations it plucks your map value so you can see that it went up quickly and then it starts to Peter off and it matches up with the loss and the accuracy the accuracy does not increase that much and the loss is barely going down my up and down back and forth so that you can decide where your best weights file would be so that you don't over fit your model so I'll show you another graph here I'll blow it up and show it on screen but you want to find the spot right here the early stopping point where you're no longer getting a better model for the amount of training you're doing so if I was looking at this model I would save that around the four thousand or three thousand training iterations that would be your final and most optimal weights file to use because you're getting thousands and thousands more iterations of training but you're barely seeing any production and accuracy and any decrease in loss so I would say that that model is being over fit so the perfect ideal weights would either be 3000 or 4000 so I'm gonna show you guys how to test that as you go through so you're gonna want to let this run and fill out I've stopped it early to show you guys this but let go fully if for some reason your crashes and your notebook crashes and you'll lose this chart PMG don't worry I'll show you guys as well how to see the map values after the fact of training so this is just what I said it saves 300 interations and you can actually kick off training again once it once it crashes or once you've stopped so that is why we saved in this backup folder so we have the weights saved and can kick off iterations you kick off training again with the last saved weights so if I ran this it would actually just kick off training from where just left off so we're gonna go ahead and see that it's starting up again and let's see the training iterations number let it go for a sec load in and it'll see that it's probably at 200 so let's check it's loaded yeah 201 so it saved every 100 and my closest 100 that I stopped it out was 200 so it's kicking off training from that 200 point and it's going to keep going towards that 6,000 iterations so it's gonna keep going and then there's a I'm gonna let that run and finish off but I just want to show you guys that alright guys I'm back I've let my model train a lot longer for a couple hours and I realized that you'll see that here I was saying every thousand weights it saves a new file and then every hundred does the last I trained for over three and a half thousand iterations I notice that since around 2000 area my model was definitely getting over fit my average loss wasn't going down at all really so I cut it off early and deemed that my model is properly changed and I'm gonna check the map values and see which one of my weights actually works the best so yeah you can cut it off really if you see that the loss isn't going down anymore it's just staying same for hundreds of iterations it's staying around the same but for beginners I'd be recommend just letting it run to completion and then testing out each of your folders you can point to each weights file within the folder and test them all to see which one's better and I'm going to show you guys how to do that so this cell here step six is checking the mean average precision of any of the weights files and comparing them to see which one is the optimal one so we just go ahead and run the cell and point it to whichever weights file you want to check the mean average precision of I'm checking it at the last one so we're going to go ahead and run that and it's gonna go ahead and print out what the mean average precision is and then we can compare so we'll just let it run it's gonna take a couple seconds here to do the calculations to see what the average precision is so here we go me and average precision is eighty eight point five seven percent that's pretty pretty solid model hopefully you want to try to get it into the low nineties if possible but this is very good and it will do the job just fine as an author protector for my license plate but I'm gonna go ahead and change the point to a different weights file so I'm going to change it to you'll be 400 square 1000 dots and I'll show you that it will be a different value so change it to 1000 and if ideally we would want this to be a smaller map value because it should be less trained and have less accuracy because of that so hopefully it shows a smaller value we'll let it calculate it up and we can see it at 1,000 our accuracy or mean average precision I should say is only seventy seven point six seven percent so a whole ten percent of less precision so that's quite a lot in fact and we can see that our last one is a lot better so you shouldn't want to do that for each of the weights files throughout your training and then you're going to want to take the one that is relatively high and it should doesn't show much change between them so for example my my old beef for object last week was about eighty eight and let's say my two thousand was eighty seven and three thousand was eighty eight is one thousand extra training iterations really good enough to get that one extra percent is that worth it or would you consider that overfitting because it trained on so many so many so many more images just to get that one percent so ideally it's just trial and error play around with and I'll show you how now how to actually test it out and see it on images so now it's time to actually run your custom object detector all you need to do is run this line to change that those two lines that I showed you earlier and your dot config for batch and subdivisions back to the testing ones so they get set back both to one and now you can actually you can go ahead and run our object detector on an image I have two hundred two car images license plates that I'm running it on and M show predictions JPEG outputs the saved image so we're gonna go ahead and I'm running it like I said on my object last weights the last saved weights and let's see if it worked and it did it worked extremely well detector seems to be working it detected the license plate almost perfectly around it I'm gonna try that again on the second M enjoy curated so I'm gonna check that on cartoon up JPEG and we run it again and hopefully it can do it again with extreme accuracy so let's check it out 93% accurate detecting the license plate and it did it in 33 milliseconds so it's tremely extremely fast and once again it has worked almost perfectly almost like Co tight that is around the license plate it's extremely accurate on detecting license plates so I would deem this to be successful and yeah that's pretty much it when it comes to training your custom object detector if you have any problems what so all please comment down below and let me know the issue and I'll try to help you out but I hope you enjoyed just a reminder that if you now want to use your custom object detector on video or use it on multiple images at once or to output to a text or JSON file you can do all of this using my previous video which you can find the code and cells in the top half of the notebook you just use for custom training so once again just reminder to use my previous video to do all those cool functions and if you enjoyed this video please toss it a like and smash that subscribe button to be up-to-date with future videos covering Yolo vie for an object detection thanks [Music]
Info
Channel: The AI Guy
Views: 115,200
Rating: undefined out of 5
Keywords: yolov4, yolov4 cloud, darknet, object detection, yolo, custom object detection, train yolo in cloud, cloud, yolov4 tutorial, yolov4 darknet, yolov3, yolo v4, google colab, object detection classifier, install yolov4, train yolov4, custom detector, custom yolov4, deep learning
Id: mmj3nxGT2YQ
Channel Id: undefined
Length: 47min 28sec (2848 seconds)
Published: Mon Jun 29 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.