ultralytics / yolov5

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

My saved data augmentation got worse result #5477

Closed datvuthanh closed 2 years ago

datvuthanh commented 2 years ago

Search before asking

Question

Hi guys,

I have a problem about data augmentation. Firstly, I used this code dataset.py to save all image augmentation files to folder (jpg). Next, I trained model with this augmentation dataset and set up augment=False. This problem is, if I setup augment=True and directly train dataset augmentation without saving, I got the better results than dataset augmentation which I saved. I don't know why results are different, whereas I checked results between two approaches many times.

Thank you.

Additional

No response

github-actions[bot] commented 2 years ago

👋 Hello @datvuthanh, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

$ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 2 years ago

@datvuthanh 👋 Hello! Thanks for asking about image augmentation. YOLOv5 🚀 applies online imagespace and colorspace augmentations in the trainloader (but not the testloader) to present a new and unique augmented Mosaic (original image + 3 random images) each time an image is loaded for training. Images are never presented twice in the same way.

YOLOv5 augmentation

The hyperparameters used to define these augmentations are in your hyperparameter file (default data/hyp.scratch.yaml) defined when training:

python train.py --hyp hyp.scratch.yaml

https://github.com/ultralytics/yolov5/blob/90b7895d652c3bd3d361b2d6e9aee900fd67f5f7/data/hyp.scratch.yaml#L1-L33

You can view the effect of your augmentation policy in your train_batch*.jpg images once training starts. These images will be in your train logging directory, typically yolov5/runs/train/exp:

train_batch0.jpg shows train batch 0 mosaics and labels:

Good luck and let us know if you have any other questions!

datvuthanh commented 2 years ago

I understand what you said, for example, you showed me 16 images augmentation. I saved all images augmentation in folder which will replace my dataset. After I train this dataset augmentation (augment=False), and I cannot achieve the results like directly train dataset augmentation without saving (augment=True). Do you understand?

glenn-jocher commented 2 years ago

@datvuthanh yes I understand. You've tried an experiment which returned a worse result, therefore the conclusion of your experiment is that the default training script works best. Go with the default training script.

datvuthanh commented 2 years ago

@glenn-jocher Thank glenn, but I want to know why the results are worse. My autoanchor without saving is 5.33 (original size), but my autoanchor with saved dataset (640x640) is only 4.3. Why? I see you calculate anchorboxes with original size (not 640x640 or 1280x1280) right?

glenn-jocher commented 2 years ago

@datvuthanh I'm sorry, we generally don't comment on users custom training results.