generated from ashleve/lightning-hydra-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor models + their Hydra configs (#142)
* Bump torch and torchvision version To get the latest version of LayerNorm * Refactor U-Net related models, layers, blocks Separate U-Net into encoder and decoder for more dynamic utilization and cleaner codes * Update LightningModule after refactoring U-Net Fix some bugs related to calling of arguments of U-Net * Add Hydra config groups for encoder and decoder * Update net Hydra configs to include encoder and decoder config groups * Fix config interpolation bug related to model.net * Update experiment_planner after refactoring model Also fix bug when producing datamodule 3D config * Allow partial instantiation of decoder in UNet * Revert "Update LightningModule after refactoring U-Net" This reverts commit 6119493. * Store some attributes in UNet to be compatible with nnUNetLitModule * Add resolver to get `in_channels` robustly from model/net * Update PDUNet with reworked UNet * Add resolver to automatically derive `dim` from `patch_size` * Add resolver to automatically derive `num_stages` from kernels * Update planner to avoid printing `dim` & `num_stages` in model config * Use resolvers to automatically derive `dim` & `num_stages` * Fix spyrit_net config * Fix typing and docstrings * Fix interpolation error in unwrap_2d data config * Add resolver to automatically determine whether to do batch dice * Update model configs * Fix typing + Remove overriding of `soft_dice_kwargs` in 3D model configs `batch_dice` is now directly derived from the patch size using resolver * Remove `dim` and `num_stages` from some forgotten model configs * Set `print_width` in prettier hook to 99 * Reformat yaml
- Loading branch information
1 parent
bd54c50
commit 4903d9a
Showing
44 changed files
with
2,735 additions
and
1,331 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
_target_: ascent.utils.loss_functions.dice_loss.DC_and_CE_loss | ||
|
||
soft_dice_kwargs: { "batch_dice": True, "smooth": 1e-5, "do_bg": False } | ||
soft_dice_kwargs: | ||
batch_dice: ${do_batch_dice:${model.net.patch_size}} | ||
smooth: 1e-5 | ||
do_bg: False | ||
ce_kwargs: {} | ||
weight_ce: 1 | ||
weight_dice: 1 |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,3 @@ | ||
_target_: ascent.models.components.convnext.ConvNeXt | ||
|
||
in_channels: ??? | ||
num_classes: ??? | ||
patch_size: ??? | ||
convnext_kernels: 7 | ||
decoder_kernels: ??? | ||
strides: [[4, 4, 4], [2, 2, 2], [2, 2, 2], [2, 2, 2]] | ||
depths: [2, 3, 3, 9, 3] | ||
filters: [32, 96, 192, 384, 768] | ||
drop_path_rate: 0 | ||
layer_scale_init_value: 1e-6 | ||
encoder_normalization_layer: "layer" | ||
decoder_normalization_layer: "instance" | ||
negative_slope: 1e-2 | ||
deep_supervision: True | ||
out_seg_bias: False | ||
defaults: | ||
- unet | ||
- override encoder: convnext |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
_target_: ascent.models.components.decoders.unet_decoder.UNetDecoder | ||
|
||
_partial_: true | ||
num_classes: ??? | ||
num_conv_per_stage: 2 | ||
output_conv_bias: True | ||
deep_supervision: True | ||
attention: False | ||
initialization: null |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
_target_: ascent.models.components.encoders.convnext.ConvNeXt | ||
|
||
in_channels: ??? | ||
num_stages: ${get_num_stages_from_kernels:${model.net.encoder.kernels}} | ||
dim: ??? | ||
stem_kernel: 7 | ||
kernels: ??? | ||
strides: ??? | ||
num_conv_per_stage: [3, 3, 9, 3] | ||
num_features_per_stage: [96, 192, 384, 768] | ||
conv_bias: True | ||
expansion_rate: 4 | ||
stochastic_depth_p: 0 | ||
layer_scale_init_value: 1e-6 | ||
conv_kwargs: null | ||
norm_layer: "group" | ||
norm_kwargs: null | ||
activation: "gelu" | ||
activation_kwargs: null | ||
drop_block: False | ||
drop_kwargs: None | ||
return_skip: True | ||
initialization: "trunc_normal" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
_target_: ascent.models.components.encoders.unet_encoder.UNetEncoder | ||
|
||
in_channels: ??? | ||
num_stages: ${get_num_stages_from_kernels:${model.net.encoder.kernels}} | ||
dim: ??? | ||
kernels: ??? | ||
strides: ??? | ||
start_features: 32 | ||
num_conv_per_stage: 2 | ||
conv_bias: True | ||
conv_kwargs: null | ||
pooling: "stride" | ||
adaptive_pooling: False | ||
norm_layer: "instance" | ||
norm_kwargs: null | ||
activation: "leakyrelu" | ||
activation_kwargs: { "inplace": True } | ||
drop_block: False | ||
drop_kwargs: None | ||
residual: False | ||
return_skip: True | ||
initialization: "kaiming_normal" |
Oops, something went wrong.