Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Probabilistic U-Net. #46

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 24 additions & 36 deletions config/softseg_unet3D_balanced.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"command": "train",
"gpu_ids": [1],
"log_directory": "msc2021_softseg_unet3D_balanced",
"gpu_ids": [0],
"log_directory": "/home/karthik7/projects/def-laporte1/karthik7/ivadomed_older_version/ivadomed/results/msc2021_softseg_unet3D_balanced",
"model_name": "ms_brain",
"debugging": true,
"object_detection_params": {
"object_detection_path": null
},
"loader_parameters": {
"bids_path": "duke/projects/ivadomed/tmp_ms_challenge_2021_preprocessed",
"path_data": "/home/karthik7/projects/def-laporte1/karthik7/ivadomed_older_version/ivadomed/datasets/tmp_ms_challenge_2021_preprocessed",
"target_suffix": ["_seg-lesion"],
"roi_params": {
"suffix": null,
Expand All @@ -32,19 +32,19 @@
"fname_split": null,
"random_seed": 42,
"center_test": [],
"balance": null,
"balance": null,
"method": "per_patient",
"train_fraction": 0.6,
"test_fraction": 0.2
},
"training_parameters": {
"batch_size": 20,
"batch_size": 16,
"loss": {
"name": "AdapWingLoss"
},
"training_time": {
"num_epochs": 200,
"early_stopping_patience": 50,
"early_stopping_patience": 75,
"early_stopping_epsilon": 0.001
},
"scheduler": {
Expand All @@ -55,7 +55,10 @@
"max_lr": 0.01
}
},
"balance_samples": {"applied": true, "type": "gt"},
"balance_samples": {
"applied": true,
"type": "gt"
},
"mixup_alpha": null,
"transfer_learning": {
"retrain_model": null,
Expand All @@ -67,53 +70,38 @@
"length_3D": [128, 128, 128],
"stride_3D": [64, 64, 64],
"attention": true,
"n_filters": 8
"n_filters": 16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually be very interested to know how much difference this makes; we should definitely do an experiment on this!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, definitely! From my experience, increasing the number of feature maps/filters helps in improving performance! Hence, I try to fit as many as possible into the memory.

},
"default_model": {
"name": "Unet",
"dropout_rate": 0.3,
"dropout_rate": 0.2,
"bn_momentum": 0.9,
"depth": 4,
"folder_name": "ms_brain",
"in_channel": 2,
"out_channel": 1,
"final_activation": "relu"
},
"postprocessing": {"binarize_prediction": {"thr": 0.5}},
"postprocessing": {
"binarize_prediction": {"thr": 0.5}
},
"transformation": {
"CenterCrop": {
"size": [
320,
384,
512
],
"size": [ 320, 384, 512 ],
"preprocessing": true
},
"RandomAffine": {
"degrees": 20,
"scale": [
0.1,
0.1,
0.1
],
"translate": [
0.1,
0.1,
0.1
],
"applied_to": [
"im",
"gt"
],
"dataset_type": [
"training"
]
"scale": [ 0.1, 0.1, 0.1 ],
"translate": [ 0.1, 0.1, 0.1 ],
"applied_to": [ "im","gt" ],
"dataset_type": [ "training" ]
},
"NumpyToTensor": {
"applied_to": ["im", "gt"]
},
"NumpyToTensor": {},
"NormalizeInstance": {
"applied_to": [
"im"
]
"applied_to": ["im"]
}
}
}
70 changes: 29 additions & 41 deletions config/softseg_unet3D_unbalanced.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"command": "train",
"gpu_ids": [0],
"log_directory": "msc2021_softseg_unet3D_unbalanced",
"gpu_ids": [2],
"log_directory": "results/msc2021_softseg_unet3D_unbalanced",
"model_name": "ms_brain",
"debugging": true,
"object_detection_params": {
"object_detection_path": null
},
"loader_parameters": {
"bids_path": "duke/projects/ivadomed/tmp_ms_challenge_2021_preprocessed",
"path_data": "duke/projects/ivadomed/tmp_ms_challenge_2021_preprocessed",
"target_suffix": ["_seg-lesion"],
"roi_params": {
"suffix": null,
Expand All @@ -32,30 +32,33 @@
"fname_split": null,
"random_seed": 42,
"center_test": [],
"balance": null,
"balance": null,
"method": "per_patient",
"train_fraction": 0.6,
"test_fraction": 0.2
},
"training_parameters": {
"batch_size": 20,
"batch_size": 16,
"loss": {
"name": "AdapWingLoss"
},
"training_time": {
"num_epochs": 200,
"early_stopping_patience": 50,
"early_stopping_patience": 75,
"early_stopping_epsilon": 0.001
},
"scheduler": {
"initial_lr": 5e-05,
"initial_lr": 2e-04,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These might be old experiments and highly dependent on the specific hyperparameters (e.g. batch size) but in my experience with the challenge lowering the learning rate was very helpful. I have seen cases where lowering the learning rate from 5e-05 to 3e-05 made a huge difference!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second this!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I really didn't know that lowering the learning rate could make that much of a difference. I am struggling to get PU-Net working for this dataset, maybe this might help to some extent! :)

"lr_scheduler": {
"name": "CosineAnnealingLR",
"base_lr": 1e-05,
"base_lr": 5e-05,
"max_lr": 0.01
}
},
"balance_samples": {"applied": false, "type": "gt"},
"balance_samples": {
"applied": false,
"type": "gt"
},
"mixup_alpha": null,
"transfer_learning": {
"retrain_model": null,
Expand All @@ -64,56 +67,41 @@
},
"Modified3DUNet": {
"applied": true,
"length_3D": [128, 128, 128],
"stride_3D": [64, 64, 64],
"length_3D": [64, 64, 64],
"stride_3D": [32, 32, 32],
"attention": true,
"n_filters": 8
"n_filters": 16
},
"default_model": {
"name": "Unet",
"dropout_rate": 0.3,
"dropout_rate": 0.2,
"bn_momentum": 0.9,
"depth": 4,
"folder_name": "ms_brain",
"in_channel": 2,
"out_channel": 1,
"final_activation": "relu"
},
"postprocessing": {"binarize_prediction": {"thr": 0.5}},
"postprocessing": {
"binarize_prediction": {"thr": 0.5}
},
"transformation": {
"CenterCrop": {
"size": [
320,
384,
512
],
"size": [ 320, 384, 512 ],
"preprocessing": true
},
"RandomAffine": {
"degrees": 20,
"scale": [
0.1,
0.1,
0.1
],
"translate": [
0.1,
0.1,
0.1
],
"applied_to": [
"im",
"gt"
],
"dataset_type": [
"training"
]
"scale": [ 0.1, 0.1, 0.1 ],
"translate": [ 0.1, 0.1, 0.1 ],
"applied_to": [ "im", "gt" ],
"dataset_type": [ "training" ]
},
"NumpyToTensor": {
"applied_to": ["im", "gt"]
},
"NumpyToTensor": {},
"NormalizeInstance": {
"applied_to": [
"im"
]
"applied_to": [ "im" ]
}
}
}
}
9 changes: 9 additions & 0 deletions modeling/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### Probabilistic U-Net for Longitudinal MS Lesion Segmentation
This contains the first attempt of using PU-Net for segmenting MS Lesions.

The current (tested) version supports single-GPU training. How to run:

```
$ export CUDA_VISIBLE_DEVICES=<your-GPU-id-here>
$ python training.py -fd 1.0
```
Loading