Training Yolo v5 on Custom Dataset for Object Detection | Roboflow Universe & Workspace

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back my name is B hammed and welcome to my YouTube channel so guys in this video I'm going to show you how we can train stateof the art object detection model with our custom data so guys many of you have already requested me for this particular video like how we can train U like object detection model with our custom data and uh many of you have already requested me for the YOLO V5 training okay so in this video I'm going to train one state of the art object detection model which is nothing but YOLO V5 and guys in this video I'm going to use some of the open source easy to use tools and technology so whenever you are training these kinds of object detection model so definitely your task would be very easy and guys uh if you check out my YouTube channel so I have already created lots of playlist on top of this computer vision and NLP and generative AI even I have also created like lots of end to end projects and all okay you can refer these are the video as well even I already showed you like how we can train YOLO V8 model YOLO V7 model YOLO V6 model okay uh so today in this video I'll also show you like how we can trade Yello V5 model because this is the most requested video okay I'm getting so uh what I will do guys first of all uh I'll show you the YOLO V5 repository so I think that would be uh clear if you don't know what is yolow V5 if you don't know YOLO V5 is a is an actually object detection uh state-of-the-art model okay and this is the performance of the yellow V5 and guys this is the official uh GitHub repository of this yellow V5 and this is the research from this ultral lytics okay this is the organization they have propose this yellow V5 model and this is like very active research as you can see only 3 days ago there was a last comment okay so if you're are having any kinds of issue with this model and all so definitely you can uh create a issue okay it would be closed uh uh very quickly so here is the installation guideline like how we can install this like repository and how we can use this yellow V5 everything they have given okay as a documentation and everything so what I have done actually uh uh I have already created one uh easy to use notebook book for you so I'll just uh show you uh the steps like how we can perform this object detection task uh how we can train our like own model OKAY own like you can say custom model with custom data so that's why actually I already prepared this notebook for you okay I will execute this notebook and I will explain okay what you need to do and if you have this notebook guys you can uh train any kinds of image okay so only you just need to change the data here and guys don't worry I will also show you some of the like free to use and open source like tools and technology so you can use them um like to do these kinds of object detection task okay so definitely your like productivity will increase there okay so uh guys what I will do first of all let me show you the data set actually I'm going to use um so guys this is the data I already collected uh I haven't collected like lots of image here because I just wanted to show you how we can train our model OKAY on top of the custom data because again I'm going to show you the annotation part of the data okay so that's why I haven't taken lots of data here but if you're training your own model make sure you have like lots of images okay so what you can do you can collect these are the images I have already collected and if you uh don't have these kinds of images and if you don't want to collect so I'll also show you one alternative you can use okay so there is a website called roof flow okay you can visit roof flow so guys robow is an amazing platform actually uh they have developed and here actually we'll get all kinds of solution in the field of computer vision so let's say you need actually data set okay for your model you want to train a model actually you need a data set okay you don't have the data set so what you can do actually Roo has one uh you can say product called Universe okay so from the universe itself you can collect the data so how to get the universe so definitely you should have one account so I already have the account so let me just loging with my account here so guys as you can see this is my account I have already logged in so if you don't have account just try to create an account with your like you can say Gmail so definitely you will get these kinds of interface and if you don't have any projects so don't worry uh you can create a projects from here I will show you how to create the projects and how to upload your data how to do The annotation everything I will show you from here only okay now here if you see guys uh here is one section called Universe okay now if you go if I go to the universe see Universe has actually different different data set okay with respect to different different task let's say you want to perform something called object detection okay you can select the object detection from here so let me select the object detection see guys um all possible actually object detection datas are available let's say you want this helmet data okay see I already took some images from here I downloaded the images from here because see I I just wanted to show you the annotation part that's why I already downloaded the data from here okay so let's say you want this this data this helmet data you can click on the data and guys if you see here lots of images are there now if you want to see that uh images okay you can open it up and this image is already annotated as you can see if I click on the image so this is already annotated see this is already annotated like uh and it is already splitted like training set testing set validation set only what you need to do you need to download this particular data okay what you can do you can directly download the data so here let's say if I click on this image so you can see uh this is already annotated as helmet as you can see now let me go back uh so guys as you can see all the image is already annotated here uh I don't need the annotated image because I I'm going to show you the annotation like how we can perform okay but if you want to uh use as it is like with The annotation form and all you can use it see see not only this data you can find lots of data let me show you so let's say if I click on object detection now let's say I want this uh I want this uh let's say this boat image okay I will click on this boat image now here you can download the data okay as you can see there is a button you can download directly you can download as a z file as well as you can also download with the code inipit see if you want to download as a z file you need to select download as Z file and here you can select the format okay like the format you want to download the data so let's say you are training YOLO V5 model so you need to select this particular option YOLO V5 pytorch let's see you are training with yolo V7 you need to select this particular uh you can say uh I mean option so that's why actually you can select different different format of the data so let's say I want to use yellow V5 pytorch I'll select it now if you want to download with the Cod snippit it will show you the Cod snippit if you want to download as a zip file you can also download as zip file so let's let me download as a z file and show you see guys if I click on export see U it is downloading uh see it is uh it will do the zip operation then it will download the data even I will also show you how we can download using Code snippit it is like very easy to use whenever we'll be uploading our custom data there and we'll be doing The annotation after that we can do it see it has started downloading the data okay as you can see uh so guys as you can see download is done now if I show you the data like how it is look like okay what is the format of this YOLO V5 because we are going to train yolow V5 definitely we need to check it and no need to worry about uh the format actually it will automatically create if you're using rlow but uh if you are using some uh open source tool okay uh let's say some open source tool are also available uh third party tool let's say there is a there is a tool called label label IMG okay so this is another tool so with the help of uh this tool actually you can also do bounding box annotation but here you need to take care about the format you need to also take care about that ENT split everything you need to take care manually okay so it is a like more time-taking task so what I feel like using roof flow it's very easy because there you don't need to organize the data so everything can be done by the platform itself okay now let me show you guys the data actually how it is look like so guys as you can see I have uh like uh here some of the folders and file so we have training set test set and inside that I have a label and image label is nothing but your uh txt annotation okay uh the yellow annotation and image contains the image actually the image actually you are going to use oh okay see all the image so that's how actually your folder will look like after uh like uh doing The annotation and all and it will have another file called data. yl okay inside data. yl you will have uh all the classes name as well as the data path actually let me show you so see guys uh here I have these are the class classes in this data and uh this is the path of the images okay and number of classes you have to Define so these are the thing actually it will automatically take care no need to worry about so I'll just uh quickly cancel this and uh what I will do I'll go back to my data so this is the data I I'm going to use called helmet data okay I have collected these are the image because uh I have uh I can't actually annotate all the image uh in this video so that's why I have taken this image but if you want use image so what you can do you can download this particular image okay here you you'll get like 1,100 and 50 49 mem so it is like enough I think to train one model now what I will do guys uh I will go back to my rlow uh so let me just uh uh close this at the tab and let me go to the rlow and here you will uh see the project section now click on the projects uh make sure you have already One account and you have signed it now here I'll create one project I'll just click on new projects and and uh here uh I'll just give the name of my project so let's say here we are doing helmet detection okay so I'll just write helmet detection now uh here you need to select the task you want to perform I want to perform object detection task okay you can also perform classification instance segmentation as well as key Point detection and semantic segmentation see all the task are possible now I'll select object detection and here you need to give The annot annotation group okay so here I want to only detect helmet so that's why I'll write helmet if you have some other also what you can do you can um if you see here this is the format they have given you can mention comma okay to represent all the uh label you have let's say you have something else okay so what you can give you can give comma or this hypen and you can write another let's say you want also hat okay that's how you can mention but I only need helmet so that's why I'll give helmet here then I will create this project so see guys my uh project has been created now you just need to upload your data so now what what you can do you can select all the data and you can just drag and drop here otherwise you can also select uh your folder you can upload this is also possible see I have already uploaded all of my data now once uh everything is good now what you need to do you need to just click on Save and continue now see guys my data is uploaded now it will uh see it has some more functionality it will tell you do you want to assign this image for uh your team member also you can also add your teammate let's say you have huge amount of data and you are working let's say seven people in a team you can divide this particular data to seven people so they they will get some of the like image to annotate okay you can also add them so this is also possible and this is a good uh I think uh uh I mean functionality they have included here so in this case I don't have any team print I'm the only one I I'll be doing The annotation so what I will do I'll just assign me you can see this is my account I have already assigned and I have 19 images here I can annotate by myself now I'll just assign the image to me now guys uh you can see here these are the unannotated image and I haven't annotated yet so that's why annotation is zero now what I will do I will start annotating so I'll just click on this button start annotating uh now guys we can start annotate the image so I want to detect this particular object which nothing but helmet so I'll select this one and uh this is the helmet object okay I'll just uh I can also press enter it will save otherwise you can also click on this button called save okay once it is done you need to click on the next image okay now let me click on the next image then again I will select my helmet make sure you are annotating u in a good way I'm just doing it quickly because I want to finish it uh uh just try to make sure you are tracking each and everything okay of the object you are annotating so try to get a um try to like uh take in a good way now this is also helmet save then uh this is all my helmet okay so guys what I will do I'll just quickly annotate for all the image I have here as you can see I have 9 19 images uh I will pause the video I'll complete and I will show you okay once it is done so guys as you can see all the 19 image has been done okay so here I have done The annotation manually uh and there is another video I created I think you remember uh in my YouTube channel so there is a tool actually from roof flow itself called uh this autod distill with the help of this Auto distill Library you can perform Auto annotation okay Image Auto annotation so make sure you are watching this particular video if you want to perform Auto annotation okay so both way you can do but but uh it depends upon you because see whenever you are doing Auto annotation also you need to give some manual observation whether everything is annotating perfectly or not okay so that's why I'm showing both process actually now see guys it is done now what I can do actually I can go back so all the image annotation is done I can go back now see guys I have annotated 19 images okay now see I need to add all the images to my data set now see it is giving the trend test split option now here you can uh like give the size how much image you actually need for the training validation and test testing so this is the default size I'll keep this size and this is the this is the number of image actually we are getting for the training validation and testing so here I have only 19 images that's why it's showing like that but uh whenever you are training your own model uh make sure you are having lots of data okay just to show you the demo I'm taking this particular image okay now what I will do I'll just add the image so it will automatically do the uh split operation now see guys it is done now if you want to see all the images now you can click here now it will show you all the imag now if you just click on the see this is The annotation you have done so everything is fine and we have also generated The annotation now what I can do I can uh I can go to the health check okay you can also check uh the health of your data whether everything is good or not you can uh see this graph actually so how many images you have how many of them you have annotated and what is the image ratio everything you can see from here now I'll just directly generate my data I'll click on generate so here you can perform some of the processing technique let's say if you want to perform resize operation Auto orientation I think you have also heard of something called augmentation technique okay in computer vision you can also perform augmentation see augmentation is also possible different different augmentation so uh you can add augmentation but I'm not going to add augmentation see you have different different augmentation you have flip augmentation 90 degree augmentation then um you have blower gray scale saturation okay all all kinds of augmentation are available so here I'm not going to perform any kinds of augmentation uh if you have very less data you can perform it but I'm not going to show it now here I will just directly create my data and let me just create the data see guys this is the version of the data it has created with the time stamp now uh you can also train with Robo flow uh you don't need to uh use any kinds of different notebook you can directly train uh with roof flow platform but for this actually you should have like uh uh like you can say premium account of them so now here what I will do I'll just export that data now here if you see uh it is telling format I will select this particular format because I'm going to use yellow V5 now here I don't want to download as Z file I will just take the code snippit so let me just generate the code snippit so this is the code snippit guys now I'll just copy this code snipp it and I'll go to my notebook and if you just go below to this notebook uh you will get this section actually so make sure you are changing this particular code and guys don't share this API key with anyone okay I'm showing because I'm just I'll will delete after the recording okay that's why I'm showing now guys as you can see uh it will automatically go go inside your projects and it will download that particular data okay now guys I need to just connect my notebook and guys now what I need to do I need to clone this particular yellow V5 repository as you can see this is the repository I need to clone then after that I will be doing some setup uh requirement setup then I can uh use this particular repository to train my yellow V5 now let me just clone this particular repository so left hand side you will see it will clone see guys it has clone now I I will be installing the requirements inside yolow V5 I have this uh requirement. txt file okay and all the requirements they have already given you have to install see I need to install them so let me just install so it will take some time let's wait so guys as you can see installation is done now what I need to do I need to download the data set from the rlow so that's why I need to install this roof flow package so roof flow um has this package actually python package you can install with the help pip and after installing you can use this code cipit you have copied from here I think you remember and you can download the data see it's done now if I execute this particular code you will see it will download the data see guys it has downloaded now if you want to check where it has downloaded now here you can check the current working directory you were in so you can write PWD so maybe I'm inside yolow V5 folder uh yeah inside yolow V5 folder now here uh if you want to check the data location where it has saved the data so you can call this particular data object and here you just write do location do location okay so if you just execute it will give you the data location see inside content yellow V5 helmet detection project one now see uh See this is the data set it has downloaded as you can see inside that I have my uh training image and uh here is the label okay that means txt annotation as you can see bounding box annotation and as well as my images also okay so everything is fine guys that means we are able to download that data and validation and all the things are available even uh my data set uh data. is also available I have one particular object uh classes called helmet and this is the classes and this thing is not required this is the some metadata from rlow and uh this is the path of the image okay that means everything is fine now what I will do guys uh if you want to check the content inside data. EML so you can execute this particular command it will take the data location and will print this particular data. EML with the help of this cat command so cat is a Linux command with the help of cat actually you can see any kinds of content in a file now guys what I need to do first of all I need to extract the number of classes actually as you can see uh inside this data. EML I have my number of classes okay like how many number of classes we are having so we have only one classes so this thing first of all I need to extract so for this actually I have written this particular code so it will open up the yl file datl file and it will extract this particular number of classes that means NC and it stored inside this variable let me show you see guys now if I print this number of classes that means it would be one it has already extracted from this particular file right as you can see it is one now what I need to do um I need to choose my model like which model you want to train here so here you have different different model configuration if I click on the model as you can see inside Yow I have model now here you have different different model okay if I also show you from the repository itself you have different different model OKAY from the model je so here I'm going to use this particular ular model called yellow v5s model this is the smallest version of the model this is the n model that's mean this is the Nano model this is the medium model this is the large model this is the X large model that's how you have uh bigger model so I I can use this particular model because I can quickly train and this is the performance of the model size and the map score then speed of the model okay and parameter it is having 7.2 million parameter and this is the Flop okay so all the configuration you can check from here so I'm going to use this particular model so for this I have this configuration yellow v5s this is the configuration now if I open this configuration you will see all the model configuration is already written and by default the number of classes is 18 here because it has trained with Coco data set okay so if you don't know Coco is a object detection uh object detection actually Benchmark data set so whenever uh anyone train any kind of object detection model they use this Coco Coco data set okay so Coco has different different actually classes okay so uh the data set they are using it is having 18 number of classes so I just need to change this particular parameter because here I doing the finding operation right I will be taking the pre-end model on top of that I will turn my custom data the data actually I'm using called helmet data so that's why I need to change this parameter uh to one so for this actually what I need to do this is the code I have written first of all if I do the cat operation on this uh yellow V5 S.L you can see all the content I just need to change this parameter so for this I have written this particular code so this code actually what it will do it will uh apply this particular rable okay on the notebook sale only okay that's why this is required this is one magic sale I have written and now see guys all the content I copied from here only if you see here all the content I copied from here I just uh uh copied all the content and here I pasted then here the number number of classes I only changed with my variable the variable I'm extracting that means one now once it is done I'm just writing okay I'm just writing inside the same folder as you can see inside model folder I'm just naming this file as custom yellow5 S.L because I don't want to change the official file okay I will be creating a copy of the file that's why I have done this particular code now if I execute this particular code you will see in the model folder it will create another particular file called custom yellow v5s dmlc now NC is equal to 1 that means we have successfully changed this parameter now we can start the training now we can see this is the training code guys it's like very easy like if you are using yellow V5 so it's like very easy to train and uh we have also seen like how to use Robo flow to prepare the data Maybe you are getting interest now see guys this is the final command so uh inside that you will see something called train file uh here is a train file train. Pi so you need to execute train. Pi here you need to define the image size this is the default size you can keep B size number of epoch you want to train so let's say I want to train only 100 Epoch okay just to show you the example so guys just to show you the demo I I'll just Train 100 Epoch because it will take time okay uh or else I can take 50 EPO it will take uh less time to train you can train with higher Epoch okay and make sure you are having lots of data okay otherwise you won't be getting any of prediction here I have only taken 19 images that's why I might not get prediction but the process will remain same okay whenever you will be using H data now here you need to pass the data yaml file path it is available in the data location I'm giving and here you need to specify the model configuration see this is the configuration we prepared this configuration path we are giving custom _ yell V5 uhml and weight I want to use this particular weight yolow v5s model okay and you need to add PT PT means the uh extension of the model file and here you need to also Define the output directory which is nothing but yellow V5 results now if I execute this particular code it will start the training first of all it will download that particular model if it is not available then um inside uh yellow V5 it will create one folder called runs let me show you see runs has been created inside runs it has created train folder inside that this is the output folder and inside that it will save all the matrics and weight see guys it has started the training and currently uh one one Epoch is going on and this is the uh box losses and uh classes losses and map score you are getting so map score should be high and losses should be low always okay whenever you are training the model so this thing I already explained in this video uh the object detection video I um created before also so I have already explained these are the thing U inside those video also okay you can check it out now see guys uh training is going on so what I will do I'll just wait I'll pause the video once this training is over I will come back so guys as you can see my training is done and it has already saved all the results in the results folder and it took 1 minutes uh 8 second to run now if you want to visualize the results actually so as you can see inside results folder it has save all the matrixes okay and this is image so I don't need to open it up from here what I can do I can directly visualize it here so inside Yow V5 uh results you have something called results.png so it is having all the matrixes okay now let me visualize it if I execute see guys you will see the results metrix see this is the losses this is the object loss and uh again loss and MMP score uh so guys uh see here I'm using very less amount of image that's why this image uh is not looking good but if you're taking like huge amount of data so there actually will see your model is learning but somehow I'm getting something now here if you want to check your batch images you can also plot them here see these are the batch images actually uh some of the batch images with the uh you can say actual annotation helmet helmet helmet you can also see the augmented image okay during run time it is also possible see what YOLO V5 do actually this framework they have developed uh it also applies this augmentation in the run time okay and these are the augmentation as you can see it has attach some of the picture it has done some brightness changes okay as you can see these are different different um augmentation they have applied now uh if you see here in the weight folder it I'm having the model OKAY b. PTL n. PT this is the model I need to use this is my train model now to check it so you can execute this particular command and I having this two model now I'll be using this b. PT to do the U inference okay on top of my test data so this is the file you need to execute that time called detect. pi as you can see detect. pi and here you need to uh pass the weight so b. PT you need to pass so here is my b. PT inside Run results wait b. PT just copy this particular um path and past it here image size confidence score and your testing image path okay so in this case this is the testing image path so let me show you inside helmet I have test and I have image now I can copy this particular path I have I'm having only two image in this particular folder now here I will just Define okay this the path now if I execute it will uh take those testing image and it will do the prediction maybe I'm not going to uh get any prediction because I'm using very less image and I trained on only 50 bux so that's why maybe I'm not I'm not going to get anything now if you want to uh see um it has also created one uh folder inside runs called detect inside detect it has created experiment and this is my prediction so let me check see no prediction is there because I already told you I'm using very less image and uh image resolution is not good also so that is why now if you want to uh show on top of this notebook you can execute this particular command it will pick up all the images from the folder and it will show you see guys okay so in case guys what you can do now you can use the roof flow roboff flow universe so I have already shown you different different data set is there you can select your task let's say object detection now you can use this particular image uh called this helmet image okay this helmet image you can download this particular image okay uh it is having uh I think I already showed you uh 1,000 uh more than 1,000 images okay uh you can see here and you can train one model on top of it and it is already annotated you can directly download this particular image okay and you can use it as it is okay so that's how actually we can uh do uh this custom Training of our YOLO V5 model okay with our custom data I hope you got it and uh you can use these are the open source tool and Technology okay just to make your task easy okay so definitely you can try with your own data guys um I hope you like this particular video and if you have likeed this particular video guys make sure uh uh you are doing subscribe to my channel and share this video with your friends and family with that guys uh thank you so much for watching this video and I'll see you next time
Info
Channel: DSwithBappy
Views: 7,233
Rating: undefined out of 5
Keywords: yolov5, yolo, object detection, computer vision, AI, Deep Learning, yolov4, yolov3, roboflow, bappy, Artificial Intelligence, yolo neural network, yolov5 custom object detection, yolov5 object detection, yolov5 tutorial, object detection yolo, object detection pytorch, object detection python, opencv object detection, opencv yolov5, opencv python yolov5, object detector, train an object detection model, object detection yolov5, the coding lib, neural networks, deep learning
Id: eo_Y3MWde60
Channel Id: undefined
Length: 27min 31sec (1651 seconds)
Published: Mon Feb 05 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.