This PR implements a refactor that moves most functionality into a fastmri PyPI-style package. The main difference is that in the previous implementation, a lot of functionality was localized to experiments, whereas in the update, functionality is moved to modules in the fastmri package so that experiments focus more on configurations and training parameters.
The basic outline for the new package structure was defined in Issue #50. This is a big update - for review, looking into train_unet_demo.py and the corresponding unet_module.py under experimental/unet is a good way to identify the main aspects of the update. A summary is as follows:
Moved a few transform operations to general fastmri operations to match practice in PyTorch (e.g., fastmri.fft2c).
Moved U-Net and VarNet PyTorch models (without PyTorch Lightning) to fastmri.models.
Created new varnet and unet folders under experimental as a central location to archive runs for reproducibility. These have a VarNetModule and a UnetModule for managing PyTorch Lightning experiments.
All models and modules now have their arguments passed directly rather than through previous PyTorch Lightning practice of using argparse hparams. This works better with linters and features like VS Code Intellisense.
Updated MriModule to handle metric aggregation across processes in ddp mode using PyTorch Lightning metrics.
Refactored tests into a separate tests folder to match pytest package practice.
Added new tests on data set sizes and basic PyTorch module training functionality.
Created a framework for centrally managing project paths with fastmri.data.mri_data.fetch_dir and a fastmri_dirs.yaml file. To create the file, run train_unet_demo.py and it will populate it with dummy paths.
Added docstrings to variational network.
Disabled custom distributed sampler when not operating in ddp mode.
VarNetModule raises an exception when batch_size=1 is not true (running with a different batch size will require implementing a custom collate_fn).
Refactored SSIM loss as fastmri.SSIMLoss.
DataTransform classes explicitly subclass object.
Updated requirements.txt.
All docstrings wrapped at 80 characters.
Formatted all updates using black.
Fixed volume_sampler.py for ddp validation with VarNet.
Tensorboard output for U-Net training:
After this future work still requires:
Updating README.md in both the varnet folder under experimental as well as the main package.
Looking into image cropping for brain cases (note: FLAIR involves partial Fourier).
Running new models and submitting to leaderboard to test for 2020 challenge functionality.
Note: I will be on PTO next week. I will look into comments two weeks from now (unless someone wants to merge this before that).
This PR implements a refactor that moves most functionality into a
fastmri
PyPI-style package. The main difference is that in the previous implementation, a lot of functionality was localized to experiments, whereas in the update, functionality is moved to modules in thefastmri
package so that experiments focus more on configurations and training parameters.The basic outline for the new package structure was defined in Issue #50. This is a big update - for review, looking into
train_unet_demo.py
and the correspondingunet_module.py
underexperimental/unet
is a good way to identify the main aspects of the update. A summary is as follows:fastmri
operations to match practice in PyTorch (e.g.,fastmri.fft2c
).fastmri.models
.varnet
andunet
folders underexperimental
as a central location to archive runs for reproducibility. These have aVarNetModule
and aUnetModule
for managing PyTorch Lightning experiments.hparams
. This works better with linters and features like VS Code Intellisense.MriModule
to handle metric aggregation across processes inddp
mode using PyTorch Lightning metrics.tests
folder to matchpytest
package practice.fastmri.data.mri_data.fetch_dir
and afastmri_dirs.yaml
file. To create the file, runtrain_unet_demo.py
and it will populate it with dummy paths.ddp
mode.VarNetModule
raises an exception whenbatch_size=1
is not true (running with a different batch size will require implementing a customcollate_fn
).fastmri.SSIMLoss
.DataTransform
classes explicitly subclassobject
.black
.volume_sampler.py
for ddp validation withVarNet
.Tensorboard output for U-Net training:
After this future work still requires:
varnet
folder underexperimental
as well as the main package.Note: I will be on PTO next week. I will look into comments two weeks from now (unless someone wants to merge this before that).