opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

[GSoC22] Data Augmentation Module in OpenCV (imgaug)

Open ZhaoChuyang opened this issue 2 years ago • 7 comments

PR for GSoC'22 project on Efficient Data Augmentation Module in OpenCV for DL Training

I implemented data augmentation methods based on basic image processing and have tested the performance of these already implemented methods in python enviroment. The following table demonstrates the running time (in seconds) comparison between OpenCV-Aug module and torchvision transforms on a subset of ImageNet:

single method:

method config dataset opencv torchvision
resize size: (200, 200) imagenet-320 0.388 1.745
center crop size: (200, 200) imagenet-320 0.001 0.017
pad padding: (100, 100, 100, 100) imagenet-320 0.141 0.553
random crop size: (200, 200) imagenet-320 0.001 0.028
random resized crop size: (500, 500) imagenet-320 0.368 3.806
random flip default imagenet-320 0.046 0.519

compose multiple methods:

method config num_augs opencv pytorch
RandomCrop + RandomFlip + Pad RandomCrop: size(300, 300) Pad: padding(100, 100, 100, 100) 3 0.481 1.240
Resize + Pad + RandomFlip + CenterCrop Resize: size(400, 400) Pad: padding(100, 100, 100, 100) CenterCrop: size(200, 200) 5 0.636 5.486

Besides augmentation methods for pure images, augmentation methods for detection task and segmentation task is also added, which requires processing the target labels of corresponding tasks.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • [x] I agree to contribute to the project under Apache 2 License.
  • [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • [x] The PR is proposed to the proper branch
  • [ ] There is a reference to the original bug report and related work
  • [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.
  • [x] The feature is well documented and sample code can be built with the project CMake

ZhaoChuyang avatar Aug 24 '22 03:08 ZhaoChuyang

Hi @kaingwade, thanks for the advice. I have added the license and add documentation for imgaug module. Junk codes in header files have also been cleaned.

ZhaoChuyang avatar Aug 29 '22 12:08 ZhaoChuyang

Hello @ZhaoChuyang!

I have added support for opencv_test_imgaug in CI. Could you push the latest commit again to re-run CI for this PR?

asenyaev avatar Sep 30 '22 16:09 asenyaev

Hi @asenyaev, I have commited the latest changes.

ZhaoChuyang avatar Oct 01 '22 06:10 ZhaoChuyang

General notes on test code:

  • There is no need to store cropped/flipped/converted images in opencv_extra, if test checks single transformation. It's better to call reference function from OpenCV itself. The test should check new logic, but not OpenCV primitives behavior.
  • Do not use ts->set_failed_test_info. It old API. Just GTest EXPECT_XXX and ASSERT_XXX are simpler and it very clean which of condition fails.

asmorkalov avatar Oct 18 '22 10:10 asmorkalov

@ZhaoChuyang Friendly reminder.

asmorkalov avatar Dec 15 '22 07:12 asmorkalov

Hi, sorry for the delay, I have been caught up in a DDL. I'll fix them ASAP.

ZhaoChuyang avatar Dec 15 '22 07:12 ZhaoChuyang

What's new about this module?

LaurentBerger avatar Apr 28 '24 18:04 LaurentBerger