YOLOv5 training with custom data

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video tutorial i will show you how you can train your yellow v5 model to detect custom object so i will show you how exactly you can create your data set for training how you can label them label them with bounding boxes i will show all of them from very scratch so let's begin so first of all to train models of course you need some images and you need to label them annotate those images so i have this folder the name of the folder is train data and inside the folder i have images and labels so inside this images i have two folder it's train and well for validation and in the train i have few images and i have simply downloaded this images from internet so it is 22 images for train and eight images for validation and here in the labels the same way right now labels are empty but i need to give labels here these images and labels names should be as it is you can give different name for train and val it will work but keep this images and labels because yellow will search for labels labels folder automatically that's why name this folder as labels and this folder as images so once you've done that inside that you can give any name these two folders just know which one is for train and which one is for validation so this is all all you need to know about this folder structure so let's label this this images i have a website where you can do it very easily and that website is makesense.ai here you don't have to upload these pictures on server it is done on javascript so it is very fast so click on get started here and you can drop images here or can get images by clicking but i will drop these images directly first let's do the train images and this 22 image loaded and i need it for object detection so click here and this part you need to give the label names and in this tutorial i will show only single label i mean single class label and that would be second and if you want multiple labels then hit enter and here you can write other things like this way but i don't need it so i'm deleting it so now start project here when here you can draw bounding boxes around these sequence and you have to select label which is only one label here so select that and this is that easy so if you want to if you want to edit labels then you can go here actions edit labels and you are in the label page again once you're done simply click on this accept you're done so label these images and for next image simply click from this window and do that same process again so here we done with with this bounding boxes now let's export this labels so for that go to this action and export annotations and here select this yellow format click on this checkbox and then export and this labels are downloaded so simply extract those labels and i'm download i'm deleting that this zip file because i got this labels folder and here these labels names of those labels are from the image names so all are here just formatted as yellow expected so for that you can see within there i'm opening with sublime text so you see here the first one is the class since here's only one class so it is zero always and here four values for bounding box so if you open that same file in this notepad you will see that in single line you won't understand here that's why i use notepad here you can see better so copy all these labels paste into the folder where we need so here images and labels and the labels since this labels from the train so paste it here and do exact same thing for this valve and for that we need images of valve now we're done with that so refresh the space now we are we can start again from start here let's drop this well images eight image loaded and label is again second start project and let's do it again so now we're done with image labeling so close this website now we have data what we need we have again images for train and for val validation and the same way the labels here and remember this folder name should be labels because it is going to detect automatically this name so our next step will be this since i'm going to use collab for training this model so let's open it and to open collab i'm going to the github page there you i can find the link for collab here the this is the official github page for yellow v5 and go little below here open in collab so let's connect collab so we are all set up in collab now run our first cell okay once you run this cell it is downloaded this folder name yellow v5 and we need to modify something in this folder and also we need to upload our data into the collab so simplest way to upload is is make it zip file and for that do it this way and you have zip file here simply drag and drop it will upload here so as it is uploading i will show you what file you need to modify in order to train from this this images so when you open this yellow v5 folder then you see this data go in there and this coco 128 yml now download this open it and you can see the structure we don't need this person anything and we don't need anything that commented and here you can see the first to train and well it is asking the file path where the train and validation images are stored anyway first look at this class names an original 128 coco 128 it had this 18 number of class so in our case we have only one class so this should be one and here should have only one class name and that is again and we almost done here just need to provide this file name i mean file path so before we do this let's set up file here so this is the zip file we just uploaded from our computer to colab this one and we need to unzip it so to unzip this it should be like this now we are done repress this first delete this zip file we don't need it anymore now we need to write this folder path here so this is all we need to do now save it whatever name you want to give here so simply do that custom data like that and now upload it upload it to the same folder wherever downloaded from here it is this is the file now i guess i have set up all the things that i need to let's go to the train training part here is the code we need to run for training these are some arguments you need to pass this is the image size this is the bad size and this is number of epoch and this is the data and here we need to keep our custom data so this is the file that we just saved here this one custom data yml so just keep that one since this have the pad there pad for this folder from where we have our custom images and we almost done so let's try with this three epoch first run this cell and since it is running first time so it is downloading this yellow v5x.pt weights are downloading so let's download first okay there is a small error it says gpu is out of memory so i think i should decrease the batch size this time it seems working so we have to wait until the training process is done even though the epoch size is three we need to increase epoch size and next time once this completes so our first experiment is successful this is trains our model in three epochs so to really work that model we need more epochs like maybe 10 epoch or maybe 20 bucks so i will try with 20 epoch and then i will show you result so let's run it and it will take little time so i will show you when this is complete so in 20 park our model could not learn so i tried few times and on 60 or more epoch i mean it need at least 60 epochs to get this accuracy so on 60 epoch see our result it is it got 97 map so it's pretty good result so if you see on the result from the run the very last one here are some result so this is the label and this is the predicted so let's compare these two so you see predicted bounding boxes are pretty good and the result is this is the labeled and this is the predictive so our model did pretty well so let's run this model for this video here i have a video [Music] of sequence and let's see how well it detects so first of all i need to upload it its size is 8mb so first upload it on this google collab and in the predict part here don't need this line and remember this weight it should be the way that is saved here from our result this wait for prediction and let's go to that place here simply replace this weight with our our weight and this source go to back video dot mp4 and i guess we set up all the things and now run this so this detection process is complete and this is saved on this this location so runs detect exp4 go to there and to watch this video we need to download it first so video is downloaded let's watch this so so as you can see it had lots of false detection and to resolve that problem simply use this conf score it give this confidence score higher say 35 percent so let's try again so after sending this confidence score i got this video so this might contain little better than previous one so it will it will have little less false detections as you can see most of them are correctly detecting [Music] even though this model is trained only on 22 images and still it's doing pretty good [Music] so here in previous time it was false detected here around but now it is not [Music] so this is all for this video and if you like this video then please like and subscribe my channel so thanks for watching [Music]
Info
Channel: DeepLearning
Views: 55,340
Rating: undefined out of 5
Keywords: yolov5 object detection, object detection, yolov5 single class, makese.ai, yolov5 custom dataset, chicken detection, image labeling, yolov5 image annotation, image annotation
Id: GRtgLlwxpc4
Channel Id: undefined
Length: 20min 29sec (1229 seconds)
Published: Tue Dec 08 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.