nnU-Net is a PyTorch-based semantic segmentation application. It will analyze the provided training cases and automatically configure a matching U-Net-based segmentation pipeline.
Allocate an interactive session and run the program. Sample session:
[user@biowulf]$ sinteractive --mem=40g --gres=gpu:v100x:1,lscratch:40 -c8 [user@cn4471 ~]$module load unet [+] Loading singularity 4.1.5 on cn4471 [+] Loading nnUNet 2.4.2The bin directory of the application includes a number of executable files:
[user@cn4471 ~]$ ls $NNUNET_BIN nnUNetv2_accumulate_crossval_results nnUNetv2_find_best_configuration nnUNetv2_apply_postprocessing nnUNetv2_move_plans_between_datasets nnUNetv2_convert_MSD_dataset nnUNetv2_plan_and_preprocess nnUNetv2_convert_old_nnUNet_dataset nnUNetv2_plot_overlay_pngs nnUNetv2_determine_postprocessing nnUNetv2_predict nnUNetv2_download_pretrained_model_by_url nnUNetv2_predict_from_modelfolder nnUNetv2_ensemble nnUNetv2_preprocess nnUNetv2_evaluate_folder nnUNetv2_train nnUNetv2_evaluate_simple python-nnunet nnUNetv2_export_model_to_zip shell nnUNetv2_extract_fingerprint [user@cn4471 ~]$mkdir /data/$USER/nnUNet && cd /data/$USER/nnUNet [user@cn4471 ~]$cp -r $NNUNET_DATA/* .Set the environment variables UNet_raw, nnUNet_preprocess and nnUNet_results. Since the nnUNet application has been installed using a singularity container and the environment variables will be used within the container, their names should be prefixed with "SINGULARITYENV_":
[user@cn4471 ~]$export SINGULARITYENV_nnUNet_raw=/data/$USER/nnUNet/nnUNet_raw [user@cn4471 ~]$export SINGULARITYENV_nnUNet_preprocessed=/data/$USER/nnUNet/nnUNet_preprocessed [user@cn4471 ~]$export SINGULARITYENV_nnUNet_results=/data/$USER/nnUNet/nnUNet_resultsNow you are ready to run the nnUNetv2_plan_and_preprocess executable:
[user@cn4471 ~]$nnUNetv2_plan_and_preprocess -h ... [user@cn4471 ~]$nnUNetv2_plan_and_preprocess -d 1 Fingerprint extraction... Dataset001_test Using <class 'nnunetv2.imageio.simpleitk_reader_writer.SimpleITKIO'> as reader/writer 100%|█████████████████████████████████████████████████████████████████████████| 10/10 [00:09<00:00, 1.03it/s] Experiment planning... ############################ INFO: You are using the old nnU-Net default planner. We have updated our recommendations. Please consider using those instead! Read more here: https://github.com/MIC-DKFZ/nnUNet/blob/master/documentation/resenc_presets.md ############################ Attempting to find 3d_lowres config. Current spacing: [1.545 1.545 1.545]. Current patch size: (np.int64(128), np.int64(128), np.int64(128)). Current median shape: [256.7961165 245.63106796 245.63106796] Attempting to find 3d_lowres config. Current spacing: [1.59135 1.59135 1.59135]. Current patch size: (np.int64(128), np.int64(128), np.int64(128)). Current median shape: [249.31661797 238.47676501 238.47676501] Attempting to find 3d_lowres config. Current spacing: [1.6390905 1.6390905 1.6390905]. Current patch size: (np.int64(128), np.int64(128), np.int64(128)). Current median shape: [242.0549689 231.53083982 231.53083982] Attempting to find 3d_lowres config. Current spacing: [1.68826322 1.68826322 1.68826322]. Current patch size: (np.int64(128), np.int64(128), np.int64(128)). Current median shape: [235.00482417 224.78722312 224.78722312] Attempting to find 3d_lowres config. Current spacing: [1.73891111 1.73891111 1.73891111]. Current patch size: (np.int64(128), np.int64(128), np.int64(128)). Current median shape: [228.16002347 218.24002245 218.24002245] Attempting to find 3d_lowres config. Current spacing: [1.79107844 1.79107844 1.79107844]. Current patch size: (np.int64(128), np.int64(128), np.int64(128)). Current median shape: [221.51458589 211.88351694 211.88351694] Attempting to find 3d_lowres config. Current spacing: [1.8448108 1.8448108 1.8448108]. Current patch size: (np.int64(128), np.int64(128), np.int64(128)). Current median shape: [215.06270475 205.71215237 205.71215237] Attempting to find 3d_lowres config. Current spacing: [1.90015512 1.90015512 1.90015512]. Current patch size: (np.int64(128), np.int64(128), np.int64(128)). Current median shape: [208.79874248 199.72053628 199.72053628] 2D U-Net configuration: {'data_identifier': 'nnUNetPlans_2d', 'preprocessor_name': 'DefaultPreprocessor', 'batch_size': 49, 'patch_size': (np.int64(256), np.int64(256)), 'median_image_size_in_voxels': array([253., 253.]), 'spacing': array([1.5, 1.5]), 'normalization_schemes': ['CTNormalization'], 'use_mask_for_norm': [False], 'resampling_fn_data': 'resample_data_or_seg_to_shape', 'resampling_fn_seg': 'resample_data_or_seg_to_shape', 'resampling_fn_data_kwargs': {'is_seg': False, 'order': 3, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_seg_kwargs': {'is_seg': True, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_probabilities': 'resample_data_or_seg_to_shape', 'resampling_fn_probabilities_kwargs': {'is_seg': False, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'architecture': {'network_class_name': 'dynamic_network_architectures.architectures.unet.PlainConvUNet', 'arch_kwargs': {'n_stages': 7, 'features_per_stage': (32, 64, 128, 256, 512, 512, 512), 'conv_op': 'torch.nn.modules.conv.Conv2d', 'kernel_sizes': ((3, 3), (3, 3), (3, 3), (3, 3), (3, 3), (3, 3), (3, 3)), 'strides': ((1, 1), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2), (2, 2)), 'n_conv_per_stage': (2, 2, 2, 2, 2, 2, 2), 'n_conv_per_stage_decoder': (2, 2, 2, 2, 2, 2), 'conv_bias': True, 'norm_op': 'torch.nn.modules.instancenorm.InstanceNorm2d', 'norm_op_kwargs': {'eps': 1e-05, 'affine': True}, 'dropout_op': None, 'dropout_op_kwargs': None, 'nonlin': 'torch.nn.LeakyReLU', 'nonlin_kwargs': {'inplace': True}}, '_kw_requires_import': ('conv_op', 'norm_op', 'dropout_op', 'nonlin')}, 'batch_dice': True} Using <class 'nnunetv2.imageio.simpleitk_reader_writer.SimpleITKIO'> as reader/writer 3D lowres U-Net configuration: {'data_identifier': 'nnUNetPlans_3d_lowres', 'preprocessor_name': 'DefaultPreprocessor', 'batch_size': 2, 'patch_size': (np.int64(128), np.int64(128), np.int64(128)), 'median_image_size_in_voxels': (209, 200, 200), 'spacing': array([1.90015512, 1.90015512, 1.90015512]), 'normalization_schemes': ['CTNormalization'], 'use_mask_for_norm': [False], 'resampling_fn_data': 'resample_data_or_seg_to_shape', 'resampling_fn_seg': 'resample_data_or_seg_to_shape', 'resampling_fn_data_kwargs': {'is_seg': False, 'order': 3, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_seg_kwargs': {'is_seg': True, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_probabilities': 'resample_data_or_seg_to_shape', 'resampling_fn_probabilities_kwargs': {'is_seg': False, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'architecture': {'network_class_name': 'dynamic_network_architectures.architectures.unet.PlainConvUNet', 'arch_kwargs': {'n_stages': 6, 'features_per_stage': (32, 64, 128, 256, 320, 320), 'conv_op': 'torch.nn.modules.conv.Conv3d', 'kernel_sizes': ((3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3)), 'strides': ((1, 1, 1), (2, 2, 2), (2, 2, 2), (2, 2, 2), (2, 2, 2), (2, 2, 2)), 'n_conv_per_stage': (2, 2, 2, 2, 2, 2), 'n_conv_per_stage_decoder': (2, 2, 2, 2, 2), 'conv_bias': True, 'norm_op': 'torch.nn.modules.instancenorm.InstanceNorm3d', 'norm_op_kwargs': {'eps': 1e-05, 'affine': True}, 'dropout_op': None, 'dropout_op_kwargs': None, 'nonlin': 'torch.nn.LeakyReLU', 'nonlin_kwargs': {'inplace': True}}, '_kw_requires_import': ('conv_op', 'norm_op', 'dropout_op', 'nonlin')}, 'batch_dice': False, 'next_stage': '3d_cascade_fullres'} 3D fullres U-Net configuration: {'data_identifier': 'nnUNetPlans_3d_fullres', 'preprocessor_name': 'DefaultPreprocessor', 'batch_size': 2, 'patch_size': (np.int64(128), np.int64(128), np.int64(128)), 'median_image_size_in_voxels': array([264.5, 253. , 253. ]), 'spacing': array([1.5, 1.5, 1.5]), 'normalization_schemes': ['CTNormalization'], 'use_mask_for_norm': [False], 'resampling_fn_data': 'resample_data_or_seg_to_shape', 'resampling_fn_seg': 'resample_data_or_seg_to_shape', 'resampling_fn_data_kwargs': {'is_seg': False, 'order': 3, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_seg_kwargs': {'is_seg': True, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'resampling_fn_probabilities': 'resample_data_or_seg_to_shape', 'resampling_fn_probabilities_kwargs': {'is_seg': False, 'order': 1, 'order_z': 0, 'force_separate_z': None}, 'architecture': {'network_class_name': 'dynamic_network_architectures.architectures.unet.PlainConvUNet', 'arch_kwargs': {'n_stages': 6, 'features_per_stage': (32, 64, 128, 256, 320, 320), 'conv_op': 'torch.nn.modules.conv.Conv3d', 'kernel_sizes': ((3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3)), 'strides': ((1, 1, 1), (2, 2, 2), (2, 2, 2), (2, 2, 2), (2, 2, 2), (2, 2, 2)), 'n_conv_per_stage': (2, 2, 2, 2, 2, 2), 'n_conv_per_stage_decoder': (2, 2, 2, 2, 2), 'conv_bias': True, 'norm_op': 'torch.nn.modules.instancenorm.InstanceNorm3d', 'norm_op_kwargs': {'eps': 1e-05, 'affine': True}, 'dropout_op': None, 'dropout_op_kwargs': None, 'nonlin': 'torch.nn.LeakyReLU', 'nonlin_kwargs': {'inplace': True}}, '_kw_requires_import': ('conv_op', 'norm_op', 'dropout_op', 'nonlin')}, 'batch_dice': True} Plans were saved to /data/user/nnUNet/nnUNet_preprocessed/Dataset001_test/nnUNetPlans.json Preprocessing... Preprocessing dataset Dataset001_test Configuration: 2d... 100%|█████████████████████████████████████████████████████████████████████████| 10/10 [00:13<00:00, 1.39s/it] Configuration: 3d_fullres... 100%|█████████████████████████████████████████████████████████████████████████| 10/10 [00:14<00:00, 1.41s/it] Configuration: 3d_lowres... 100%|█████████████████████████████████████████████████████████████████████████| 10/10 [00:41<00:00, 4.16s/it]End the interactive session:
[user@cn4471 ~]$ exit salloc.exe: Relinquishing job allocation 46116226 [user@biowulf ~]$
sbatch [--cpus-per-task=#] [--mem=#] unet.sh