facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
29.98k stars 7.4k forks source link

Detectron2 Augmentation Dataloader in-place or copy of image #4463

Open asluborski98 opened 2 years ago

asluborski98 commented 2 years ago

In regards to the Augmentation techniques in Detectron2 and using a custom dataloader. I was wondering when doing these augmentations is there a copy of the image being made and then doing the augmentation (in effect increasing our dataset and still training on the original image)? Or is it taking our image in the dataset and doing a augmentation in-place randomly?

I haven't seen this stated explicitly anywhere unless I missed it.

I ask because I want to increase my dataset with augmented images since it is small in size.

Thank you for any clarification

Robotatron commented 2 years ago

Every time the model "sees" an image the image get's randomly augmented. Depending on the augmentation settings the model might never "see" a original image. So yea, it's done in place.

DanielDimanov commented 1 year ago

Which is strange, because for me without augmentations and batch size of 6 with 2 workers I'm okay and with augmentations, batch size of 2 and 1 worker my CUDA OOMs, so I think it stores a copy of the original in memory or at least it doesn't release the memory after. My augmentations were simply RandomBrightness and RandomContrast. I can't seem to get any augmentations to work even after reducing my RPN.BATCH_SIZE_PER_IMAGE 4 times and allowing mixed precission. Detectron2 is definitely not handling data mappers efficiently.

alrightkami commented 1 year ago

@DanielDimanov I had the same issue. Fixed it by saving generated by Detectron2 augmented images and adding them to the dataset manually. Training obviously takes more time, but batch_size may stay the same

luca-serra commented 10 months ago

In regards to the Augmentation techniques in Detectron2 and using a custom dataloader. I was wondering when doing these augmentations is there a copy of the image being made and then doing the augmentation (in effect increasing our dataset and still training on the original image)? Or is it taking our image in the dataset and doing a augmentation in-place randomly?

I haven't seen this stated explicitly anywhere unless I missed it.

I ask because I want to increase my dataset with augmented images since it is small in size.

Thank you for any clarification

Hi! I was wondering the exact same thing! I also want to add as many images as augmentations. Anyone has a snippet of code achieving this?