How To Prepare Datasets For Training YOLOv5 Object Detection- Official - YOLOV5 Training

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
how to prepare a custom yellow v5 object detection data set for training in this video we will learn what is yolo v5 data set format how to prepare a data set for training and what are the best practices what tools can you use to make your life easy let's say we want to train a three-class object detector for detecting cats dogs and persons we will use the label zero for cat one for dog and two for the person class to get started you have to obtain thousands of images containing cats dogs and persons notice that every image can include one or more of these classes should you use some images that contain none of these classes the answer is yes a small percentage let's say less than 10 can help you reduce false positives how many images do we need now that's a tricky question if the classes that you're trying to detect are very different then you need a few hundred images on the other hand if you want to differentiate between similar things like breeds of dogs you need a few thousand images or a few thousand examples of each class once you have collected all the images you need to create one file per image containing the ground truth metadata about the location of objects inside the image for yellow v5 this file has the same file name as the original image file but it has a dot txt extension txt is obviously a text file if there are no objects in the image for example if you want to include some background image to reduce false positives we do not need this text file you can only add an image file and that's sufficient inside this file we have one row per object in the image in this example we have two objects a cat and a dog therefore the file has two rows every row has five numbers the first is the id of the class in our example the ids are zero and one for the cat and the dog respectively the second and the third entries in the row are for the object's center the fourth and the fifth are for the width and height of the object now as you can see these numbers are in normalized coordinates you need to multiply the x-coordinate with the width of the image and the y-coordinate with the height of the image to get the real image code names while creating this data set you have to make sure of the following things first try to make the data set balanced you should not have 1000 images of cats and just 20 images of dogs label every instance of every class in the image so if there is a cat a dog or a person in the image you have to find the bounding boxes for all of them in the ground truth metadata file if you miss cats dogs or people your detector will perform very poorly make sure your data set has a lot of variety this could mean that you have to include different breeds of cats dogs the people in the data set should be wearing different kinds of clothes they must have different body shapes images should be taken under different lighting conditions we want variety the higher the variance of your data set the richer information it has fourth the annotation should be consistent for example in this image there are two ways of labeling the cat in the person's hand your bounding box could include only part of the cat that is visible or your bounding box could include the entire cat both are valid choices you could go with either one of them but you have to make sure that you're consistent in your choice if you are labeling one image with a certain kind of bounding box you should use the same strategy for some other image inconsistent bounding boxes can create a lot of problems as well next we divide the image into training validation and test sets the training set is part of your data you train your model on the validation set is part of your data on which you check how the model is performing the validation set is not actually seen by the model it's not used in the training process it's only used to see how well the model is performing but because the validation set is used to check the accuracy during training and improve the model the accuracy reported by the validation set tends to be optimistic if you try this model on real data from real world you will see that the validation accuracy is usually higher than real world accuracy and for that reason sometimes we hold back a part of the data set and we call it the test set this set is used exclusively for reporting the final accuracy we usually split the data set into 60 training 20 validation and 20 test set but frankly very often we simply do not have the test set we just split the data set into 80 training set and 20 validation set and we say that you know the accuracy reported on the validation set is good enough although we know that it is slightly optimistic while doing this split we have to make sure that this splitting of training and validation sets is done randomly and this splitting doesn't have any systematic bias this is very important after you have done the split you should go and check out the training set you should check the validation set and make sure that there is no systematic bias you have not added or you have not introduced a bias just the way you have split the data set so far we have gathered a few thousand images we have created one file per image that contains bounding boxes and class ids for every object in the image we have then split the data set into two parts training and validation set now we have to make this data set usable for yellow v5 training to do this we move the files into the following directory structure create a top-level directory called data and inside it create two sub-directories images and labels inside the images directory create two sub-directories train and valve similarly inside the labels directory create two subdirectories train and valve as you can see all the training data will go in the train directory and the validation will go into val directory so you move all the images in the training set to images slash train and images in the validation set to images slash val similarly we move the ground truth metadata training files to labels slash train and validation set files to labels slash val the final step is to create a yaml file needed by the training script this yaml which is spelled as yaml file contains the path to all the data relative to the training set it also needs the path to the training and validation images as shown here and the training script automatically figures out the path to the ground truth metadata files by replacing the words images in the path with labels so be very careful while using this keywords images and labels in your path because they will be replaced by the training script to figure out automatically what is the path to the ground truth metadata files we also need to specify this variable nc which stands for number of classes in this case it is three finally we need to specify the names of classes which in our case is cat dog and person that's all you need to train your object detection model using yellow v5 we'll cover custom training of a yellow v5 model in a separate video but before we end this video we want to share the names of a few tools that can help you with data set preparation the easiest way to quickly prepare your data set including labeling and exporting directly into yellow v5 format is roboflow it is the official data set management tool for yellow v5 you can also use the tool cvat which stands for computer vision annotation tool it is open source and it is free to use at cvat.org other labeling tools like makesense.ai or label box also work just fine that's all i wanted to cover in this video this is sacha malik signing off your guide to the fascinating world of computer vision and ai thank you
Info
Channel: LearnOpenCV
Views: 29,872
Rating: undefined out of 5
Keywords: ai, machine learning, object detection, yolov5 object detection tutorial, yolov5 training, yolov5 custom dataset github, yolov5 object detection python, yolov5 dataset download, yolov5 classes list, How can I learn YOLOv5?, How many epochs should I train YOLOv5?, How many pictures do you need to train YOLOv5?, How do you train models for object detection?
Id: wM1wn1bZ3S4
Channel Id: undefined
Length: 9min 2sec (542 seconds)
Published: Mon May 02 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.