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

274 add multi organ segmentation bundle #275

Merged
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6ac1190
Bundle for abdominal multi-organ segmentation
cshen0625 Dec 14, 2022
d5214ed
Update the readme
cshen0625 Dec 14, 2022
c3f0014
Update the readme
cshen0625 Dec 14, 2022
28b57bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 14, 2022
2ccc77d
modify the permissions
cshen0625 Dec 20, 2022
d7e03b0
update the permission
cshen0625 Dec 20, 2022
21e5eea
Merge branch 'dev' into 274-multi_organ_segmentation
cshen0625 Dec 20, 2022
1c16bf2
update perimission
cshen0625 Dec 20, 2022
3348181
update perimission
cshen0625 Dec 20, 2022
9a62715
merge
cshen0625 Dec 20, 2022
b8cb478
update permissions
cshen0625 Dec 20, 2022
2465fab
update permissions
cshen0625 Dec 20, 2022
8cedb4f
update permissions
cshen0625 Dec 20, 2022
4341bff
update
cshen0625 Dec 20, 2022
aa8c895
update
cshen0625 Dec 20, 2022
0d8ccce
update the data specification on README
cshen0625 Dec 27, 2022
b476e10
remove the license
cshen0625 Dec 27, 2022
7d89774
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Dec 28, 2022
a593cbf
update README
cshen0625 Jan 5, 2023
e480135
update README
cshen0625 Jan 5, 2023
89d26e4
update
cshen0625 Jan 5, 2023
1c0f4e9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 5, 2023
5145a95
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Jan 5, 2023
7d5641a
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Jan 12, 2023
408cd75
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Jan 16, 2023
28922e3
update license
cshen0625 Jan 23, 2023
b3c509a
update license
cshen0625 Jan 23, 2023
7d55481
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 23, 2023
b0c05d2
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Jan 30, 2023
4104e72
modify license and change bundle root dir
yiheng-wang-nv Feb 10, 2023
06b3448
[MONAI] code formatting
monai-bot Feb 10, 2023
2587549
add new version number for changed bundles
yiheng-wang-nv Feb 10, 2023
0dbc4dd
modify input type in metadata
yiheng-wang-nv Feb 10, 2023
d6ae6b8
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Feb 13, 2023
177044b
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Mar 13, 2023
885627d
update the license
cshen0625 Apr 18, 2023
08401e9
update
cshen0625 Apr 18, 2023
928f45b
update license
cshen0625 Apr 18, 2023
4c1ec6c
update the training schema
cshen0625 May 1, 2023
10430d8
restore to the original license
cshen0625 May 2, 2023
e8ffaaf
update bundle commands and configs
holgerroth May 13, 2023
c693d6e
Merge branch 'dev' of github.com:Project-MONAI/model-zoo into 274-mul…
holgerroth May 13, 2023
d7a1163
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv May 17, 2023
b23fd7f
retrain for new MONAI
cshen0625 Jun 23, 2023
bc3255b
retrain for new MONAI
cshen0625 Jun 23, 2023
1a132e4
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Jun 25, 2023
9ad7cfa
test on stable MONAI version
cshen0625 Jun 27, 2023
c0a6c54
pull the latest monai
cshen0625 Jun 27, 2023
9baec78
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Jun 28, 2023
eb67ebf
update the hash info
cshen0625 Jun 28, 2023
0386b9e
pull the latest model zoo
cshen0625 Jun 28, 2023
9ede024
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Jun 30, 2023
3d1ecb6
update metadata
cshen0625 Jul 11, 2023
6987242
Merge branch 'dev' into 274-multi_organ_segmentation
yiheng-wang-nv Jul 13, 2023
2a8d230
update the license on README.md
cshen0625 Jul 25, 2023
b0caa0d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2023
024668e
Merge branch 'dev' into 274-multi_organ_segmentation
holgerroth Jul 25, 2023
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
Empty file.
1,688 changes: 1,688 additions & 0 deletions multi_organ_segmentation/configs/dataset_0.json

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions multi_organ_segmentation/configs/evaluate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
validate#postprocessing:
_target_: Compose
transforms:
- _target_: Activationsd
keys: pred
softmax: true
- _target_: Invertd
keys:
- pred
- label
transform: "@validate#preprocessing"
orig_keys: image
meta_key_postfix: meta_dict
nearest_interp:
- false
- true
to_tensor: true
- _target_: AsDiscreted
keys:
- pred
- label
argmax:
- true
- false
to_onehot: 8
- _target_: CopyItemsd
keys: "pred"
times: 1
names: "pred_save"
- _target_: AsDiscreted
keys:
- pred_save
argmax:
- true
- _target_: SaveImaged
keys: pred_save
meta_keys: pred_meta_dict
output_dir: "@output_dir"
resample: false
squeeze_end_dims: true
validate#dataset:
_target_: Dataset
data: "@val_datalist"
transform: "@validate#preprocessing"
validate#handlers:
- _target_: CheckpointLoader
load_path: "$@ckpt_dir + '/model.pt'"
load_dict:
model: "@network"
- _target_: StatsHandler
iteration_log: false
- _target_: MetricsSaver
save_dir: "@output_dir"
metrics:
- val_mean_dice
- val_acc
metric_details:
- val_mean_dice
batch_transform: "$monai.handlers.from_engine(['image_meta_dict'])"
summary_ops: "*"
evaluating:
- "$setattr(torch.backends.cudnn, 'benchmark', True)"
- "$@validate#evaluator.run()"
116 changes: 116 additions & 0 deletions multi_organ_segmentation/configs/inference.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
imports:
- "$import glob"
- "$import os"
input_channels: 1
output_classes: 8
arch_ckpt_path: "$@bundle_root + '/models/search_code_18590.pt'"
arch_ckpt: "$torch.load(@arch_ckpt_path, map_location=torch.device('cuda'))"
bundle_root: "/work/"
output_dir: "$@bundle_root + '/eval'"
dataset_dir: "/data/"
data_list_file_path: "$@bundle_root + '/configs/dataset_0.json'"
datalist: "$monai.data.load_decathlon_datalist(@data_list_file_path, data_list_key='testing',
base_dir=@dataset_dir)"
device: "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')"
dints_space:
_target_: monai.networks.nets.TopologyInstance
channel_mul: 1
num_blocks: 12
num_depths: 4
use_downsample: true
arch_code:
- "$@arch_ckpt['arch_code_a']"
- "$@arch_ckpt['arch_code_c']"
device: "$torch.device('cuda')"
network_def:
_target_: monai.networks.nets.DiNTS
dints_space: "@dints_space"
in_channels: "@input_channels"
num_classes: "@output_classes"
use_downsample: true
node_a: "$torch.from_numpy(@arch_ckpt['node_a'])"
network: "$@network_def.to(@device)"
preprocessing:
_target_: Compose
transforms:
- _target_: LoadImaged
keys: image
- _target_: EnsureChannelFirstd
keys: image
- _target_: Orientationd
keys: image
axcodes: RAS
- _target_: Spacingd
keys: image
pixdim:
- 1
- 1
- 1
mode: bilinear
- _target_: ScaleIntensityRanged
keys: image
a_min: -500
a_max: 500
b_min: 0
b_max: 1
clip: true
- _target_: EnsureTyped
keys: image
dataset:
_target_: Dataset
data: "@datalist"
transform: "@preprocessing"
dataloader:
_target_: DataLoader
dataset: "@dataset"
batch_size: 1
shuffle: false
num_workers: 4
inferer:
_target_: SlidingWindowInferer
roi_size:
- 96
- 96
- 96
sw_batch_size: 4
overlap: 0.625
postprocessing:
_target_: Compose
transforms:
- _target_: Activationsd
keys: pred
softmax: true
- _target_: Invertd
keys: pred
transform: "@preprocessing"
orig_keys: image
meta_key_postfix: meta_dict
nearest_interp: false
to_tensor: true
- _target_: AsDiscreted
keys: pred
argmax: true
- _target_: SaveImaged
keys: pred
meta_keys: pred_meta_dict
output_dir: "@output_dir"
handlers:
- _target_: CheckpointLoader
load_path: "$@bundle_root + '/models/model.pt'"
load_dict:
model: "@network"
- _target_: StatsHandler
iteration_log: false
evaluator:
_target_: SupervisedEvaluator
device: "@device"
val_data_loader: "@dataloader"
network: "@network"
inferer: "@inferer"
postprocessing: "@postprocessing"
val_handlers: "@handlers"
amp: true
evaluating:
- "$setattr(torch.backends.cudnn, 'benchmark', True)"
- "[email protected]()"
21 changes: 21 additions & 0 deletions multi_organ_segmentation/configs/logging.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[loggers]
keys=root

[handlers]
keys=consoleHandler

[formatters]
keys=fullFormatter

[logger_root]
level=INFO
handlers=consoleHandler

[handler_consoleHandler]
class=StreamHandler
level=INFO
formatter=fullFormatter
args=(sys.stdout,)

[formatter_fullFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
90 changes: 90 additions & 0 deletions multi_organ_segmentation/configs/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
"version": "0.0.1",
"changelog": {
"0.0.1": "initialize the model package structure"
},
"monai_version": "1.0.1",
"pytorch_version": "1.13.0",
"numpy_version": "1.21.2",
"optional_packages_version": {
"fire": "0.4.0",
"nibabel": "4.0.1",
"pytorch-ignite": "0.4.9"
},
"task": "Multi-organ segmentation in abdominal CT",
"description": "DiNTS architectures for volumetric (3D) segmentation of the abdominal from CT image",
"authors": "Chen Shen, Holger R. Roth, Kazunari Misawa, Kensaku Mori",
"copyright": "",
"data_source": "Aichi Cancer Center, Japan",
"data_type": "nibabel",
"image_classes": "single channel data, intensity scaled to [0, 1]",
"label_classes": "eight channels data, 1 is artery, 2 is portal vein, 3 is liver, 4 is spleen, 5 is stomach, 6 is gallbladder, 7 is pancreas, 0 is everything else",
"pred_classes": "8 channels OneHot data, 1 is artery, 2 is portal vein, 3 is liver, 4 is spleen, 5 is stomach, 6 is gallbladder, 7 is pancreas, 0 is background",
"eval_metrics": {
"mean_dice": 0.88
},
"references": [
"He, Y., Yang, D., Roth, H., Zhao, C. and Xu, D., 2021. Dints: Differentiable neural network topology search for 3d medical image segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (pp. 5841-5850).",
"Roth, H., Shen C, Oda H., Sugino T., Oda M., Hayashi Y., Misawa K., Mori K., 2018. A multi-scale pyramid of 3D fully convolutional networks for abdominal multi-organ segmentation. International conference on medical image computing and computer-assisted intervention",
"Shen, C., Roth, H. R., Nath, V., Hayashi, Y., Oda, M., Misawa, K., Mori, K., 2022. Effective hyperparameter optimization with proxy data for multi-organ segmentation. In Medical Imaging 2022: Image Processing (Vol. 12032, pp. 200-206)"
],
"network_data_format": {
"inputs": {
"image": {
"type": "image",
"format": "hounsfield",
"modality": "CT",
"num_channels": 1,
"spatial_shape": [
96,
96,
96
],
"dtype": "float64",
"value_range": [
0,
1
],
"is_patch_data": true,
"channel_def": {
"0": "image"
}
}
},
"outputs": {
"pred": {
"type": "image",
"format": "segmentation",
"num_channels": 8,
"spatial_shape": [
96,
96,
96
],
"dtype": "float32",
"value_range": [
0,
1,
2,
3,
4,
5,
6,
7
],
"is_patch_data": true,
"channel_def": {
"0": "background",
"1": "artery",
"2": "portal vein",
"3": "liver",
"4": "spleen",
"5": "stomach",
"6": "gallbladder",
"7": "pancreas"
}
}
}
}
}
52 changes: 52 additions & 0 deletions multi_organ_segmentation/configs/multi_gpu_train.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
device: "$torch.device(f'cuda:{dist.get_rank()}')"
network:
_target_: torch.nn.parallel.DistributedDataParallel
module: "$@network_def.to(@device)"
find_unused_parameters: true
device_ids:
- "@device"
optimizer#lr: "$0.025*dist.get_world_size()"
lr_scheduler#step_size: "$80*dist.get_world_size()"
train#handlers:
- _target_: LrScheduleHandler
lr_scheduler: "@lr_scheduler"
print_lr: true
- _target_: ValidationHandler
validator: "@validate#evaluator"
epoch_level: true
interval: "$10*dist.get_world_size()"
- _target_: StatsHandler
tag_name: train_loss
output_transform: "$monai.handlers.from_engine(['loss'], first=True)"
- _target_: TensorBoardStatsHandler
log_dir: "@output_dir"
tag_name: train_loss
output_transform: "$monai.handlers.from_engine(['loss'], first=True)"
train#trainer#max_epochs: "$400*dist.get_world_size()"
train#trainer#train_handlers: "$@train#handlers[: -2 if dist.get_rank() > 0 else None]"
validate#evaluator#val_handlers: "$None if dist.get_rank() > 0 else @validate#handlers"
training:
- "$import torch.distributed as dist"
- "$dist.init_process_group(backend='nccl')"
- "$torch.cuda.set_device(@device)"
- "$monai.utils.set_determinism(seed=123)"
- "$setattr(torch.backends.cudnn, 'benchmark', True)"
- "$@train#trainer.run()"
- "$dist.destroy_process_group()"
train_data_partition: "$monai.data.partition_dataset(data=@train_datalist, num_partitions=dist.get_world_size(),
shuffle=True, even_divisible=True,)[dist.get_rank()]"
train#dataset:
_target_: CacheDataset
data: "@train_data_partition"
transform: "@train#preprocessing"
cache_rate: 0.3
num_workers: 4
val_data_partition: "$monai.data.partition_dataset(data=@val_datalist, num_partitions=dist.get_world_size(),
shuffle=False, even_divisible=False,)[dist.get_rank()]"
validate#dataset:
_target_: CacheDataset
data: "@val_data_partition"
transform: "@validate#preprocessing"
cache_rate: 0.3
num_workers: 4
Loading