Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.91k stars 1.09k forks source link

Support Mixup and Cutmix transformation #2872

Closed JiYuanFeng closed 8 months ago

JiYuanFeng commented 3 years ago

HI, the more strong transformation "RandCoarseDropout" has been released in the latest version. It's possible to support Mixup or Cutmix in MonAI? image

Nic-Ma commented 3 years ago

Hi @JiYuanFeng ,

Thanks for your feedback. Seems like a new transform feature request, I marked for feature discussion. @ericspod @wyli Do you guys think it's a common approach in medical imaging augmentation?

Thanks in advance.

Thanks.

wyli commented 3 years ago

for the mixup, I can find this paper as a reference https://openreview.net/pdf?id=rkBBChjiG. not sure if we have an example/renference for cutmix.

sandylaker commented 3 years ago

@wyli For CutMix, you can refer to this paper. These two augmentations mix one image with another randomly selected one, which can be selected from the same batch or the whole dataset. Thus, the API of these two augmentations are slightly different from the other ones.

wyli commented 3 years ago

Thanks, I think these are good augmentations to have. @Nic-Ma these could be in v0.8?

Nic-Ma commented 3 years ago

Sounds good to me. I can try to implement in v0.8.

Thanks.

Nic-Ma commented 3 years ago

Hi @wyli ,

Currently, all the MONAI transforms work with a single image, so I think maybe this feature is not a transform, It should be a layer before the network to mix up a batch data?

Thanks.

ericspod commented 3 years ago

My thoughts on mixup that I wanted to play with at some point was as a special sort of DataLoader that would combine images from a batch to make a smaller batch with some controls for how the mixing would be done. Alternatively if we wanted to do it as a transform we would have to first create a dataset of image pairs that are to be mixed (this wouldn't involve copying the original images though so should be lightweight), a normal transform sequence, and a final transform that does the mixing of the two images to produce one. This can get us around the issue of transform sequences being one-to-one for the most part, they operate on individual items in a batch rather than being able to operate on a whole batch.

masadcv commented 3 years ago

@Nic-Ma Just to add to discussion here, there is an existing implementation of this for medical images, perhaps for paper @wyli linked (https://openreview.net/pdf?id=rkBBChjiG), in NiftNet at: https://github.com/NifTK/NiftyNet/blob/935bf4334cd00fa9f9d50f6a95ddcbfdde4031e0/niftynet/application/segmentation_application.py#L325

Nic-Ma commented 3 years ago

Hi @masadcv ,

Thanks for your sharing. Let me investigate it and get back ASAP.

Thanks.

JohnMasoner commented 1 year ago

Hi @Nic-Ma ,

It seems that Mixup and Cutmix are still unsupported.

Is there any consideration to include this data transformation method? Because I've been working on related content lately, if consider adding these transformations. I will submit pr.

Thanks.

Nic-Ma commented 1 year ago

Hi @JohnMasoner ,

Thanks for your interest here. If @ericspod and @wyli don't have any other comments, welcome to contribute a PR.

JohnMasoner commented 1 year ago

Thanks for your reply,

I readed @ericspod comments, i will contribute a PR about CutOut( Maybe like 'RandCoarseDropout', also similar to Mixup and Cutmix)

ericspod commented 1 year ago

Hi @JohnMasoner, thanks for looking into this. I'd definitely like to see some contributions along the lines of mixup/cutmix, something new you're working on would be great as well as reference implementations of what's been published already. I had suggested implementing it as a dataloader of some sort but it's possible to be instead a special collate function, or some other implementation entirely, so feel free to propose your own solution.