balbasty / nitorch

Neuroimaging in PyTorch
Other
83 stars 14 forks source link

Added augmentation to neural network models. #43

Closed brudfors closed 3 years ago

brudfors commented 3 years ago

Closes #40.

I got a recursive import error, so I decided to move segmentation.py to a new folder in nn, called models.

A function called add_augmenters is now part of the base nn module, supposed to be populated by a user. As augmentation is quite task-specific, I put it in segmentation.py for segmentation augmentation.

This is how it could be added to a segmentation model:

from nitorch.nn.models.segmentation import augmentation
model.add_augmenter(lambda x, y: augmentation('warp', x, y))
model.add_augmenter(lambda x, y: augmentation('inu', x, y))
model.add_augmenter(lambda x, y: augmentation('noise', x, y))

@balbasty, what do you think of the implementation and structure?

balbasty commented 3 years ago

The circular import just comes from your augmentation function in the segmentation file no? Why not keep SegNet in modules and have the augmentation function in generators?

i have added comments directly to the commit

brudfors commented 3 years ago

The circular import just comes from your augmentation function in the segmentation file no? Why not keep SegNet in modules and have the augmentation function in generators?

i have added comments directly to the commit

I can't seem to find your comments in the commit?

brudfors commented 3 years ago

Moved the augmentation into a new module in generators.

balbasty commented 3 years ago

The circular import just comes from your augmentation function in the segmentation file no? Why not keep SegNet in modules and have the augmentation function in generators?

i have added comments directly to the commit

I can't seem to find your comments in the commit?

There are 8 comments that appear on this PR on my side. Can you see them? That's what I was referring to

brudfors commented 3 years ago

The circular import just comes from your augmentation function in the segmentation file no? Why not keep SegNet in modules and have the augmentation function in generators?

i have added comments directly to the commit

I can't seem to find your comments in the commit?

There are 8 comments that appear on this PR on my side. Can you see them? That's what I was referring to

Do you mean the comment are on the code in the commit, which I can reach by, on this page, clicking Commits and then clicking on my initial commit? No, I cannot see any comments there.