-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Support Imgaug for augmentations in the data pipeline. #492
Conversation
Codecov Report
@@ Coverage Diff @@
## master #492 +/- ##
==========================================
+ Coverage 84.67% 84.76% +0.09%
==========================================
Files 121 121
Lines 8526 8579 +53
Branches 1398 1416 +18
==========================================
+ Hits 7219 7272 +53
Misses 953 953
Partials 354 354
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This library looks interesting. Do you know the typical use cases? Any mixed usage of imgaug and normal augmentation pipelines? |
Imgaug (and most of the other data augmentation libs) is desined for single image augmentation(eg. blur/rotate/crop/pad/resize...), along with all kinds of labels(detection, segmentation, keypoints). So when dealing ava dataset, no need to take care of bbox separately
pipeline = [
dict(
type='SampleFrames',
clip_len=1,
frame_interval=1,
num_clips=16,
),
dict(type='RawFrameDecode'),
dict(type='Resize', scale=(-1, 256)),
dict(
type='MultiScaleCrop',
input_size=224,
scales=(1, 0.875, 0.75, 0.66),
random_crop=False,
max_wh_scale_gap=1,
num_fixed_crops=13),
dict(type='Resize', scale=(224, 224), keep_ratio=False),
dict(type='Flip', flip_ratio=0.5),
dict(type='Imgaug', transforms='default'),
# dict(type='Imgaug', transforms=[dict(type='Rotate', rotate=(-30, 30))]),
dict(type='FormatShape', input_format='NCHW'),
dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),
dict(type='ToTensor', keys=['imgs', 'label'])
] However, imgaug pipeline only generates/modifies 4 keys I was planing to create a config file, using imgaug to replace all normal augmentation pipelines. But imgaug doesn't support all mmaction2 augmentation pipelines, especially the crop/resize. After this pr is merged, I'll also create a pr to support albumentations, which is also a third party data augmentation library and more popular nowadays. |
Very interesting. If you have trained some models that benefit from this augmentation, could you please share some with us? BTW, there are many other augmentation packages such as https://github.com/hassony2/torch_videovision, https://github.com/torchvideo/torchvideo, https://github.com/DemisEom/SpecAugment that might be helpful. Especially this one https://github.com/piergiaj/pytorch-i3d/blob/master/videotransforms.py, which applies augmentation by volume slicing rather than for looping. @innerlee Will it be faster? |
no |
@innerlee , I am not sure about that. I have done a toy test:
This gives a result of: Since we do the for-loop slicing and convert it into numpy array afterward, when taking |
I haven't tried these augmenters to train kinetics-400. When training our own datasets, blur/rotate helps. My original intention is to try everything. For now, speed is not my priority. So I prefer 3rd party libraries with more augmenters(imgaug and albumentations). If we can all benefit from certain augmenters, we can implements those in the future. BTW, |
you may need to pull the new master and rebase to it. |
94c3e72
to
5e13636
Compare
kindly ping @dreamerlin @SuX97 |
@innerlee any suggestions for this pr? |
Quite busy this week, will take a look next Wed. Thanks for the patience |
kindly ping @innerlee |
bc5fcce
to
baad691
Compare
It will be great to add an example (runnable) config in tsn/ or i3d/ folder |
Found a serious bug: training failed when using imgaug and multi-gpu. Works fine when training with single-gpu(i used to do). Will try to fix this in two weeks.
|
try putting import in call function instead of init |
2. add tsn/i3d demo config 3. add assert for in&out dtype 4. update docs
@congee524 Please train a checkpoint for these two configs, and upload them in a separate pr, thx! |
Support imgaug in dataset pipeline.
Some of these codes are modified from mmdet.
Any suggestions about this PR?