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

Questions about images that are augmentation during Train #4705

Closed LEEGILJUN closed 2 years ago

LEEGILJUN commented 3 years ago

Dear Developers,

I have a few questions while studying yolo v5.

I known what the hyperparameters for image augmentation are from the link below https://github.com/ultralytics/yolov5/issues/607 https://github.com/ultralytics/yolov5/issues/4342

I'm asking because I don't understand the code about augmentation working

  1. How many images are created when I use the augmentation method when Train? If all 9 parameters are operated, it will be x9 times the original image when am I training?

  2. For example, when all augmentation methods are applied to images, Is it possible to control how many times the total amount of training image data is compared to the original image?

  3. Is only one augmentation method applied to one image? Or can multiple augmentation methods be applied to one image?

  4. Does augmentation only work when I am Train or Test? and is the augmentation image was included when test or validation?

  5. Is there a function to save the multiplied image augmentation?

  6. last year, yolov5 is included test.py and detect.py but now only val.py. what is different between test.py and val.py

glenn-jocher commented 3 years ago

@LEEGILJUN šŸ‘‹ 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!

LEEGILJUN commented 3 years ago

Hello Thank you for answer. Since the question is not resolved, I will ask again.

  1. If the number of original training images is 1000, how many images are there in total after augmentation??
  2. I understood your answer as follows. The original image and 9 augmentation methods are used to create a mosaic with 1+3 combined. So is the augmentation applied to the original images randomly to make a mosaic? When I use all 12 hyper-parameters??
  3. How many mosaic images were finally created?? Can I instead of saving this as a batch image, save it in a separate folder

Thank you

glenn-jocher commented 3 years ago

@LEEGILJUN 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.

github-actions[bot] commented 3 years ago

šŸ‘‹ Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 šŸš€ resources:

Access additional Ultralytics āš” resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 šŸš€ and Vision AI ā­!