-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring: lightning API package and smoke tests (#161)
### Description I moved the lightning modules into their own package to clarify the imports for the different API, and added smoke tests for the Lightning API. As a result I needed to implement a new function to retrieve the statistics from the `CAREamicsTrainData`, which led me to refactor a bit the datasets and standardize how the statistics are recorded across the two datasets. The smoke tests check that the Lightning API works for tiled and un-tiled data. Finally, the lightning modules wrappers have disappeared, and now convenience functions explicit the parameters. This led to renaming of the lightning modules. - **What**: - Moved Lightning modules and callbacks to `careamics.lightning` - Added tests for the Lightning API (tiled and un-tiled prediction included) - Normalize the way the datasets keep the image statistics. - Fixed some errors in `CAREamicsTrainData` - **Why**: Since we are differentiating between CAREamist and Lightning APIs, they should be imported from different packages. - **How**: - Moved Lightning modules and callbacks to `careamics.lightning` - Added tests for Ligthning API. - Removed `StatsOutput`, both datasets now have a `self.image_stats: Stats` and `self.target_stats: Stats` - Added `get_data_statistics` to the datasets and `CAREamicsTrainData` and corresponding test ### Changes Made - **Added**: `test_lightning_api.py`. - **Modified**: - `ligthning_data_module.py` - `Iterable_dataset.py` - `in_memory_dataset.py` - `patching.py` - imports throughout the careamist and other files ### Additional Notes and Examples To use the Lightning API, users now need to have the following imports: ```python from pytorch_lightning import Trainer from pytorch_lightning.callbacks import ModelCheckpoint from careamics.lightning import ( CAREamicsModuleWrapper, TrainingDataWrapper, PredictDataWrapper, ) from careamics.prediction_utils import convert_outputs # if tiling required ``` (see [full example here](https://github.com/CAREamics/careamics-examples/blob/jd/lightning_api/applications/lightning_api/2D/BSD68_Noise2Void_lightning_api.ipynb)) Since the `PredictDataWrapper` requires passing the statistics, users can now simply call: ```python means, stds = train_data_wrapper.get_data_statistics() ``` While building the notebook, I uncovered the following error: #162 --- **Please ensure your PR meets the following requirements:** - [x] Code builds and passes tests locally, including doctests - [x] New tests have been added (for bug fixes/features) - [x] Pre-commit passes - [ ] PR to the documentation exists (for bug fixes / features) - CAREamics/careamics-examples#6 - CAREamics/careamics.github.io#11 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
f223aa7
commit ff20596
Showing
29 changed files
with
722 additions
and
1,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.