ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.77k stars 16.35k forks source link

Dataset report while training #5373

Closed iumyx2612 closed 3 years ago

iumyx2612 commented 3 years ago

❔Question

This line pops up when I start the train.py train: Scanning '../Dataset/labels/train' images and labels...2711 found, 19 missing, 2 empty, 0 corrupted: 100% 2730/2730 [11:22<00:00, 4.00it/s] Can you explain what is "missing", "empty" and "corrupted"?

Additional context

glenn-jocher commented 3 years ago

@iumyx2612 missing means an image missing labels (which is fine, this is a background image), empty means an empty labelfile, which is also fine, and corrupted means an error.

iumyx2612 commented 3 years ago

@iumyx2612 missing means an image missing labels (which is fine, this is a background image), empty means an empty labelfile, which is also fine, and corrupted means an error.

Thank you very much

iumyx2612 commented 3 years ago

@iumyx2612 missing means an image missing labels (which is fine, this is a background image), empty means an empty labelfile, which is also fine, and corrupted means an error.

Is there anyway to print the name of background images, empty label files and corrupted file? It's really hard to go inspect every single file in a large dataset

glenn-jocher commented 3 years ago

@iumyx2612 all corrupted images are printed to console.

Missing and empty labels are not problematic and are not printed to screen. These are simply considered background images.

iumyx2612 commented 3 years ago

I fear that those considered background images could be because of me forgot to label them. So I want to print them out just in case. And is there anyway to get the exact number of instances per classes from the training dataset? I see the labels.jpg but I don't know how to get the exact number of instances

glenn-jocher commented 3 years ago

@iumyx2612 val.py outputs counts per class. You can run on your train set with --task train

!python val.py --task train --verbose

val: data=data/coco128.yaml, weights=yolov5s.pt, batch_size=32, imgsz=640, conf_thres=0.001, iou_thres=0.6, task=train, device=, single_cls=False, augment=False, verbose=True, save_txt=False, save_hybrid=False, save_conf=False, save_json=False, project=runs/val, name=exp, exist_ok=False, half=False
YOLOv5 🚀 v6.0-39-g5d4258f torch 1.9.0+cu111 CUDA:0 (Tesla P100-PCIE-16GB, 16280.875MB)

Fusing layers... 
Model Summary: 213 layers, 7225885 parameters, 0 gradients
train: Scanning '../datasets/coco128/labels/train2017.cache' images and labels... 128 found, 0 missing, 2 empty, 0 corrupted: 100% 128/128 [00:00<?, ?it/s]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00,  1.21s/it]
                 all        128        929      0.669      0.537      0.621       0.41
              person        128        254      0.769      0.682      0.775      0.504
             bicycle        128          6      0.709        0.5      0.563      0.349
...
            scissors        128          1          1          0     0.0158    0.00316
          teddy bear        128         21      0.897      0.429      0.589      0.354
          toothbrush        128          5          1      0.583      0.651      0.425
Speed: 0.2ms pre-process, 6.1ms inference, 4.3ms NMS per image at shape (32, 3, 640, 640)
Results saved to runs/val/exp2

There is no method for listing empty images currently.

iumyx2612 commented 3 years ago

@iumyx2612 val.py outputs counts per class. You can run on your train set with --task train

!python val.py --task train --verbose

val: data=data/coco128.yaml, weights=yolov5s.pt, batch_size=32, imgsz=640, conf_thres=0.001, iou_thres=0.6, task=train, device=, single_cls=False, augment=False, verbose=True, save_txt=False, save_hybrid=False, save_conf=False, save_json=False, project=runs/val, name=exp, exist_ok=False, half=False
YOLOv5 🚀 v6.0-39-g5d4258f torch 1.9.0+cu111 CUDA:0 (Tesla P100-PCIE-16GB, 16280.875MB)

Fusing layers... 
Model Summary: 213 layers, 7225885 parameters, 0 gradients
train: Scanning '../datasets/coco128/labels/train2017.cache' images and labels... 128 found, 0 missing, 2 empty, 0 corrupted: 100% 128/128 [00:00<?, ?it/s]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00,  1.21s/it]
                 all        128        929      0.669      0.537      0.621       0.41
              person        128        254      0.769      0.682      0.775      0.504
             bicycle        128          6      0.709        0.5      0.563      0.349
...
            scissors        128          1          1          0     0.0158    0.00316
          teddy bear        128         21      0.897      0.429      0.589      0.354
          toothbrush        128          5          1      0.583      0.651      0.425
Speed: 0.2ms pre-process, 6.1ms inference, 4.3ms NMS per image at shape (32, 3, 640, 640)
Results saved to runs/val/exp2

There is no method for listing empty images currently.

Thank you very much

iumyx2612 commented 3 years ago

@iumyx2612 all corrupted images are printed to console.

Missing and empty labels are not problematic and are not printed to screen. These are simply considered background images.

Are corrupted images got deleted after the scan? I uploaded them to google drive to train on google colab but they are no where to be found in my drive

glenn-jocher commented 3 years ago

@iumyx2612 no, YOLOv5 does not delete any images.

SuJackie commented 1 year ago

@iumyx2612val.py 輸出每個類的計數。你可以在你的火車上運行--task train

!python val.py --task train --verbose

val: data=data/coco128.yaml, weights=yolov5s.pt, batch_size=32, imgsz=640, conf_thres=0.001, iou_thres=0.6, task=train, device=, single_cls=False, augment=False, verbose=True, save_txt=False, save_hybrid=False, save_conf=False, save_json=False, project=runs/val, name=exp, exist_ok=False, half=False
YOLOv5 🚀 v6.0-39-g5d4258f torch 1.9.0+cu111 CUDA:0 (Tesla P100-PCIE-16GB, 16280.875MB)

Fusing layers... 
Model Summary: 213 layers, 7225885 parameters, 0 gradients
train: Scanning '../datasets/coco128/labels/train2017.cache' images and labels... 128 found, 0 missing, 2 empty, 0 corrupted: 100% 128/128 [00:00<?, ?it/s]
               Class     Images     Labels          P          R     mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00,  1.21s/it]
                 all        128        929      0.669      0.537      0.621       0.41
              person        128        254      0.769      0.682      0.775      0.504
             bicycle        128          6      0.709        0.5      0.563      0.349
...
            scissors        128          1          1          0     0.0158    0.00316
          teddy bear        128         21      0.897      0.429      0.589      0.354
          toothbrush        128          5          1      0.583      0.651      0.425
Speed: 0.2ms pre-process, 6.1ms inference, 4.3ms NMS per image at shape (32, 3, 640, 640)
Results saved to runs/val/exp2

What does Class all mean? What does the number of Labels mean?

glenn-jocher commented 1 year ago

@SuJackie The "Class all" in the output of val.py refers to the overall performance metrics for all classes combined. It provides an aggregated evaluation of the model's precision (P), recall (R), and mean average precision (mAP) at the IoU threshold of 0.5.

The "Labels" column represents the total number of ground truth labels present in the dataset, indicating the number of instances across all classes that the model is trained and evaluated on.

SuJackie commented 1 year ago

@glenn-jocher Does empty mean negative samples? How do I check the number of positive and negative samples for training? How to check the number of Labels in a certain class during training?

Thank you

glenn-jocher commented 1 year ago

@SuJackie empty labels typically refer to images that do not contain any objects of interest and therefore do not have any corresponding bounding box labels. They can be considered as negative samples or background images.

To check the number of positive and negative samples for training, you can use the train.py script with the --data argument pointing to your dataset YAML file. After you start training, the script will output a line similar to the following:

train: Scanning 'path/to/labels/train' images and labels... X found, Y missing, Z empty, C corrupted

Here, "X" represents the total number of images with labels that are found, "Y" represents the number of images that are missing labels, "Z" represents the number of images with empty labels, and "C" represents the number of corrupted images.

To check the number of labels in a certain class during training, you can use the val.py script with the --task train argument. This will provide a detailed report showing the number of images and labels for each class, as well as precision, recall, and mAP (mean average precision) metrics.

SuJackie commented 1 year ago

@glenn-jocher I trained in two class (garbage and bottle) but there were many misidentifications as stones. Do I need to add the stone class to my training dataset(as a negative samples)?

I really appreciate your help

glenn-jocher commented 1 year ago

@SuJackie hi there!

Including a separate "stone" class in your training dataset might not necessarily address the issue of misidentifications. Since stones are being misidentified as either "garbage" or "bottle," it's likely that there might be a similarity between the appearance of stones and these objects.

To improve the accuracy of your model, you can try the following steps:

  1. Collect more diverse and representative data for the "garbage" and "bottle" classes, including different variations and angles.
  2. Augment your existing dataset by applying transformations such as rotation, scaling, and flipping to enhance the model's ability to generalize.
  3. Experiment with different hyperparameters, such as adjusting the learning rate or increasing the number of training iterations, to fine-tune the model.
  4. Consider using a larger variant of YOLOv5 (e.g., yolov5m or yolov5l) which may have better performance on more complex or crowded scenes.

Remember, training a YOLO model is an iterative process, so it might require several iterations of data collection, model training, and evaluation to achieve better results.

Hope this helps! Let me know if you have any further questions.