The different setting methods of YOLOV5 training labels have a great impact on the test results. Why???? #7370
Replies: 4 comments 3 replies
-
@Peter-Pan-GitHub 👋 Hello! Thanks for asking about YOLOv5 🚀 dataset formatting. To train correctly your data must be in YOLOv5 format. Please see our Train Custom Data tutorial for full documentation on dataset setup and all steps required to start training your first model. A few excerpts from the tutorial: 1.1 Create dataset.yamlCOCO128 is an example small tutorial dataset composed of the first 128 images in COCO train2017. These same 128 images are used for both training and validation to verify our training pipeline is capable of overfitting. data/coco128.yaml, shown below, is the dataset config file that defines 1) the dataset root directory # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: ../datasets/coco128 # dataset root dir
train: images/train2017 # train images (relative to 'path') 128 images
val: images/train2017 # val images (relative to 'path') 128 images
test: # test images (optional)
# Classes
nc: 80 # number of classes
names: [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
'hair drier', 'toothbrush' ] # class names 1.2 Create LabelsAfter using a tool like Roboflow Annotate to label your images, export your labels to YOLO format, with one
The label file corresponding to the above image contains 2 persons (class 1.3 Organize DirectoriesOrganize your train and val images and labels according to the example below. YOLOv5 assumes ../datasets/coco128/images/im0.jpg # image
../datasets/coco128/labels/im0.txt # label Good luck 🍀 and let us know if you have any other questions! |
Beta Was this translation helpful? Give feedback.
-
In my view, I prefer to use the first method that you have mentioned above as the object detector generalized better under such a circumstance than the latter. The training of classification with multiple labels typically converges better than do it with a single label. Moreover, a poor skill of annotation also is deemed as a factor that might lead to lower accuracy because the content of background might be taken into consideration during the training process. |
Beta Was this translation helpful? Give feedback.
-
of course, you get this result. Basically Your 2nd way to prepare the training set introducing lots of contradictions. The yolo learns the image like a sliding window. You can think of an example you have exactly 2 objects in each image, with equally sized. Basically you have 1 positive example and 1 negative example per each image per class. Your 1st way is correct. However, your 2nd way actually give 2 conflicted result. Say in copy1 you have 1 positive example for object A, but you then label the B as negative. in copy2 you reversed it. Thus you feed into the mode 2 exact same examples per class, but you label them as 1 negative and 1 positive. Of course you model is going to learn nothing about it. |
Beta Was this translation helpful? Give feedback.
-
As long as I know, all fully convolutional network architectures work with an assigner to assign the labels in the correct feature at the last feature map of the network. To be balance the assigner must have both positive and negative examples in each input. So, in Yolo all anchors that have a big enough IoU with ROI is labeled are positives or class-i examples and all others as negative or background examples. |
Beta Was this translation helpful? Give feedback.
-
There are 400 pictures, each picture has 5 targets, that is, a total of 2000 labels. I used the following two methods to train, and after many training and test comparisons, I found that the test results of these two methods are very different:
The first way: 400 jpg image files + 400 txt tag files, that is, each txt tag file corresponds to an image, and each txt file contains 5 tags
The second way: 2000 jpg image files + 2000 txt label files, that is, I copy each picture into 5 copies, and rename them, and then generate 2000 txt label files correspondingly, each txt label file only label one target object for each picture.
Please do not consider it's superfluous, my actual request is like this. What I understand is that these two training methods should have similar effects, and there is not much difference between the conclusions. Why is there a big difference in the actual test? ? ? ?
The test effect of the first method is much better than the second. The first way: P, R, and MAP are all high; the second way: only R is high, and both P and MAP are low. When using the second method for testing, there is almost no target frame. Even if there is a target frame, there is only one target frame, and the accuracy rate is very low; But the first method will frame all the targets, and the accurate rate is also very high.
Beta Was this translation helpful? Give feedback.
All reactions