├── ADAM_Postprocess.py ├── ADAM_Preprocess.py ├── LICENSE ├── README.md ├── input └── 10040 │ ├── aneurysms.nii.gz │ └── location.txt ├── nnUNet ├── documentation │ ├── data_format_inference.md │ ├── dataset_conversion.md │ ├── extending_nnunet.md │ ├── inference_example_Prostate.md │ ├── setting_up_paths.md │ └── training_example_Hippocampus.md ├── nnunet │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── configuration.cpython-37.pyc │ │ └── paths.cpython-37.pyc │ ├── configuration.py │ ├── dataset_conversion │ │ ├── Task017_BeyondCranialVaultAbdominalOrganSegmentation.py │ │ ├── Task024_Promise2012.py │ │ ├── Task027_AutomaticCardiacDetectionChallenge.py │ │ ├── Task029_LiverTumorSegmentationChallenge.py │ │ ├── Task032_BraTS_2018.py │ │ ├── Task035_ISBI_MSLesionSegmentationChallenge.py │ │ ├── Task037_038_Chaos_Challenge.py │ │ ├── Task040_KiTS.py │ │ ├── Task043_BraTS_2019.py │ │ ├── Task055_SegTHOR.py │ │ ├── Task056_VerSe2019.py │ │ ├── Task056_Verse_normalize_orientation.py │ │ ├── Task058_ISBI_EM_SEG.py │ │ ├── Task059_EPFL_EM_MITO_SEG.py │ │ ├── Task061_CREMI.py │ │ ├── Task062_NIHPancreas.py │ │ ├── Task064_KiTS_labelsFixed.py │ │ ├── Task065_KiTS_NicksLabels.py │ │ ├── Task069_CovidSeg.py │ │ └── __init__.py │ ├── evaluation │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── evaluator.cpython-37.pyc │ │ │ ├── metrics.cpython-37.pyc │ │ │ └── region_based_evaluation.cpython-37.pyc │ │ ├── add_dummy_task_with_mean_over_all_tasks.py │ │ ├── add_mean_dice_to_json.py │ │ ├── collect_results_files.py │ │ ├── evaluator.py │ │ ├── metrics.py │ │ ├── model_selection │ │ │ ├── __init__.py │ │ │ ├── collect_all_fold0_results_and_summarize_in_one_csv.py │ │ │ ├── ensemble.py │ │ │ ├── figure_out_what_to_submit.py │ │ │ ├── rank_candidates.py │ │ │ ├── rank_candidates_StructSeg.py │ │ │ ├── rank_candidates_cascade.py │ │ │ ├── summarize_results_in_one_json.py │ │ │ └── summarize_results_with_plans.py │ │ ├── region_based_evaluation.py │ │ └── surface_dice.py │ ├── experiment_planning │ │ ├── DatasetAnalyzer.py │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── DatasetAnalyzer.cpython-37.pyc │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── common_utils.cpython-37.pyc │ │ │ ├── experiment_planner_baseline_2DUNet.cpython-37.pyc │ │ │ ├── experiment_planner_baseline_2DUNet_v21.cpython-37.pyc │ │ │ ├── experiment_planner_baseline_3DUNet.cpython-37.pyc │ │ │ ├── experiment_planner_baseline_3DUNet_v21.cpython-37.pyc │ │ │ ├── nnUNet_convert_decathlon_task.cpython-37.pyc │ │ │ ├── nnUNet_plan_and_preprocess.cpython-37.pyc │ │ │ ├── summarize_plans.cpython-37.pyc │ │ │ └── utils.cpython-37.pyc │ │ ├── alternative_experiment_planning │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── experiment_planner_baseline_3DUNet_v21_11GB.cpython-37.pyc │ │ │ │ ├── experiment_planner_baseline_3DUNet_v21_32GB.cpython-37.pyc │ │ │ │ ├── experiment_planner_baseline_3DUNet_v21_3convperstage.cpython-37.pyc │ │ │ │ ├── experiment_planner_baseline_3DUNet_v22.cpython-37.pyc │ │ │ │ ├── experiment_planner_baseline_3DUNet_v23.cpython-37.pyc │ │ │ │ └── experiment_planner_residual_3DUNet_v21.cpython-37.pyc │ │ │ ├── experiment_planner_baseline_3DUNet_v21_11GB.py │ │ │ ├── experiment_planner_baseline_3DUNet_v21_32GB.py │ │ │ ├── experiment_planner_baseline_3DUNet_v21_3convperstage.py │ │ │ ├── experiment_planner_baseline_3DUNet_v22.py │ │ │ ├── experiment_planner_baseline_3DUNet_v23.py │ │ │ ├── experiment_planner_residual_3DUNet_v21.py │ │ │ ├── normalization │ │ │ │ ├── __init__.py │ │ │ │ ├── experiment_planner_3DUNet_CT2.py │ │ │ │ └── experiment_planner_3DUNet_nonCT.py │ │ │ ├── patch_size │ │ │ │ ├── __init__.py │ │ │ │ ├── experiment_planner_3DUNet_isotropic_in_mm.py │ │ │ │ └── experiment_planner_3DUNet_isotropic_in_voxels.py │ │ │ ├── pooling_and_convs │ │ │ │ ├── __init__.py │ │ │ │ ├── experiment_planner_baseline_3DUNet_allConv3x3.py │ │ │ │ └── experiment_planner_baseline_3DUNet_poolBasedOnSpacing.py │ │ │ ├── readme.md │ │ │ └── target_spacing │ │ │ │ ├── __init__.py │ │ │ │ └── experiment_planner_baseline_3DUNet_targetSpacingForAnisoAxis.py │ │ ├── common_utils.py │ │ ├── experiment_planner_baseline_2DUNet.py │ │ ├── experiment_planner_baseline_2DUNet_v21.py │ │ ├── experiment_planner_baseline_3DUNet.py │ │ ├── experiment_planner_baseline_3DUNet_v21.py │ │ ├── nnUNet_convert_decathlon_task.py │ │ ├── nnUNet_plan_and_preprocess.py │ │ ├── old │ │ │ ├── __init__.py │ │ │ └── old_plan_and_preprocess_task.py │ │ ├── summarize_plans.py │ │ └── utils.py │ ├── inference │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── predict.cpython-37.pyc │ │ │ ├── predict_simple.cpython-37.pyc │ │ │ └── segmentation_export.cpython-37.pyc │ │ ├── change_trainer.py │ │ ├── ensemble_predictions.py │ │ ├── predict.py │ │ ├── predict_simple.py │ │ ├── pretrained_models │ │ │ ├── __init__.py │ │ │ ├── collect_pretrained_models.py │ │ │ └── download_pretrained_model.py │ │ └── segmentation_export.py │ ├── network_architecture │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── generic_UNet.cpython-37.pyc │ │ │ ├── generic_UNet_DP.cpython-37.pyc │ │ │ ├── generic_modular_UNet.cpython-37.pyc │ │ │ ├── generic_modular_residual_UNet.cpython-37.pyc │ │ │ ├── initialization.cpython-37.pyc │ │ │ └── neural_network.cpython-37.pyc │ │ ├── custom_modules │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── conv_blocks.cpython-37.pyc │ │ │ │ ├── feature_response_normalization.cpython-37.pyc │ │ │ │ ├── helperModules.cpython-37.pyc │ │ │ │ └── mish.cpython-37.pyc │ │ │ ├── conv_blocks.py │ │ │ ├── feature_response_normalization.py │ │ │ ├── helperModules.py │ │ │ └── mish.py │ │ ├── generic_UNet.py │ │ ├── generic_UNet_DP.py │ │ ├── generic_modular_UNet.py │ │ ├── generic_modular_residual_UNet.py │ │ ├── initialization.py │ │ └── neural_network.py │ ├── paths.py │ ├── postprocessing │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── connected_components.cpython-37.pyc │ │ │ └── consolidate_postprocessing.cpython-37.pyc │ │ ├── connected_components.py │ │ ├── consolidate_all_for_paper.py │ │ ├── consolidate_postprocessing.py │ │ └── consolidate_postprocessing_simple.py │ ├── preprocessing │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── cropping.cpython-37.pyc │ │ │ ├── preprocessing.cpython-37.pyc │ │ │ └── sanity_checks.cpython-37.pyc │ │ ├── cropping.py │ │ ├── preprocessing.py │ │ └── sanity_checks.py │ ├── run │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── default_configuration.cpython-37.pyc │ │ │ └── run_training.cpython-37.pyc │ │ ├── default_configuration.py │ │ ├── run_training.py │ │ ├── run_training_DDP.py │ │ └── run_training_DP.py │ ├── training │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ └── model_restore.cpython-37.pyc │ │ ├── cascade_stuff │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ └── predict_next_stage.cpython-37.pyc │ │ │ └── predict_next_stage.py │ │ ├── data_augmentation │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── custom_transforms.cpython-37.pyc │ │ │ │ ├── default_data_augmentation.cpython-37.pyc │ │ │ │ ├── downsampling.cpython-37.pyc │ │ │ │ └── pyramid_augmentations.cpython-37.pyc │ │ │ ├── custom_transforms.py │ │ │ ├── default_data_augmentation.py │ │ │ ├── downsampling.py │ │ │ └── pyramid_augmentations.py │ │ ├── dataloading │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ └── dataset_loading.cpython-37.pyc │ │ │ └── dataset_loading.py │ │ ├── learning_rate │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ └── poly_lr.cpython-37.pyc │ │ │ └── poly_lr.py │ │ ├── loss_functions │ │ │ ├── ND_Crossentropy.py │ │ │ ├── TopK_loss.py │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── ND_Crossentropy.cpython-37.pyc │ │ │ │ ├── TopK_loss.cpython-37.pyc │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── deep_supervision.cpython-37.pyc │ │ │ │ └── dice_loss.cpython-37.pyc │ │ │ ├── deep_supervision.py │ │ │ └── dice_loss.py │ │ ├── model_restore.py │ │ ├── network_training │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── network_trainer.cpython-37.pyc │ │ │ │ ├── nnUNetTrainer.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerCascadeFullRes.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2_CascadeFullRes.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2_DDP.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2_DP.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2_Loss_Dice.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2_Loss_DiceTopK10.cpython-37.pyc │ │ │ │ └── nnUNetTrainerV2_fp32.cpython-37.pyc │ │ │ ├── network_trainer.py │ │ │ ├── nnUNetTrainer.py │ │ │ ├── nnUNetTrainerCascadeFullRes.py │ │ │ ├── nnUNetTrainerV2.py │ │ │ ├── nnUNetTrainerV2_CascadeFullRes.py │ │ │ ├── nnUNetTrainerV2_DDP.py │ │ │ ├── nnUNetTrainerV2_DP.py │ │ │ ├── nnUNetTrainerV2_Loss_Dice.py │ │ │ ├── nnUNetTrainerV2_Loss_DiceTopK10.py │ │ │ ├── nnUNetTrainerV2_fp32.py │ │ │ └── nnUNet_variants │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerCE.cpython-37.pyc │ │ │ │ └── nnUNetTrainerNoDA.cpython-37.pyc │ │ │ │ ├── architectural_variants │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_3ConvPerStage.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_3ConvPerStage_samefilters.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_BN.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_FRN.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_GN.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_GeLU.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_LReLU_slope_2en1.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Mish.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_NoNormalization.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_NoNormalization_lr1en3.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_ReLU.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_ReLU_biasInSegOutput.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_ReLU_convReLUIN.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_ResencUNet.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_allConv3x3.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_lReLU_biasInSegOutput.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_lReLU_convlReLUIN.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_noDeepSupervision.cpython-37.pyc │ │ │ │ │ └── nnUNetTrainerV2_softDeepSupervision.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2_3ConvPerStage.py │ │ │ │ ├── nnUNetTrainerV2_3ConvPerStage_samefilters.py │ │ │ │ ├── nnUNetTrainerV2_BN.py │ │ │ │ ├── nnUNetTrainerV2_FRN.py │ │ │ │ ├── nnUNetTrainerV2_GN.py │ │ │ │ ├── nnUNetTrainerV2_GeLU.py │ │ │ │ ├── nnUNetTrainerV2_LReLU_slope_2en1.py │ │ │ │ ├── nnUNetTrainerV2_Mish.py │ │ │ │ ├── nnUNetTrainerV2_NoNormalization.py │ │ │ │ ├── nnUNetTrainerV2_NoNormalization_lr1en3.py │ │ │ │ ├── nnUNetTrainerV2_ReLU.py │ │ │ │ ├── nnUNetTrainerV2_ReLU_biasInSegOutput.py │ │ │ │ ├── nnUNetTrainerV2_ReLU_convReLUIN.py │ │ │ │ ├── nnUNetTrainerV2_ResencUNet.py │ │ │ │ ├── nnUNetTrainerV2_allConv3x3.py │ │ │ │ ├── nnUNetTrainerV2_lReLU_biasInSegOutput.py │ │ │ │ ├── nnUNetTrainerV2_lReLU_convlReLUIN.py │ │ │ │ ├── nnUNetTrainerV2_noDeepSupervision.py │ │ │ │ └── nnUNetTrainerV2_softDeepSupervision.py │ │ │ │ ├── cascade │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2CascadeFullRes_DAVariants.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2CascadeFullRes_lowerLR.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2CascadeFullRes_shorter.cpython-37.pyc │ │ │ │ │ └── nnUNetTrainerV2CascadeFullRes_shorter_lowerLR.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2CascadeFullRes_DAVariants.py │ │ │ │ ├── nnUNetTrainerV2CascadeFullRes_lowerLR.py │ │ │ │ ├── nnUNetTrainerV2CascadeFullRes_shorter.py │ │ │ │ └── nnUNetTrainerV2CascadeFullRes_shorter_lowerLR.py │ │ │ │ ├── copies │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ │ └── nnUNetTrainerV2_copies.cpython-37.pyc │ │ │ │ └── nnUNetTrainerV2_copies.py │ │ │ │ ├── data_augmentation │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_DA2.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_independentScalePerAxis.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_insaneDA.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_noDA.cpython-37.pyc │ │ │ │ │ └── nnUNetTrainerV2_noMirroring.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2_DA2.py │ │ │ │ ├── nnUNetTrainerV2_independentScalePerAxis.py │ │ │ │ ├── nnUNetTrainerV2_insaneDA.py │ │ │ │ ├── nnUNetTrainerV2_noDA.py │ │ │ │ └── nnUNetTrainerV2_noMirroring.py │ │ │ │ ├── loss_function │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_ForceBD.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_ForceSD.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Loss_CE.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Loss_CEGDL.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Loss_Dice.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Loss_DiceTopK10.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Loss_Dice_lr1en3.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Loss_Dice_squared.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Loss_MCC.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Loss_TopK10.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_focalLoss.cpython-37.pyc │ │ │ │ │ └── nnUNetTrainerV2_graduallyTransitionFromCEToDice.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2_ForceBD.py │ │ │ │ ├── nnUNetTrainerV2_ForceSD.py │ │ │ │ ├── nnUNetTrainerV2_Loss_CE.py │ │ │ │ ├── nnUNetTrainerV2_Loss_CEGDL.py │ │ │ │ ├── nnUNetTrainerV2_Loss_Dice.py │ │ │ │ ├── nnUNetTrainerV2_Loss_DiceTopK10.py │ │ │ │ ├── nnUNetTrainerV2_Loss_Dice_lr1en3.py │ │ │ │ ├── nnUNetTrainerV2_Loss_Dice_squared.py │ │ │ │ ├── nnUNetTrainerV2_Loss_MCC.py │ │ │ │ ├── nnUNetTrainerV2_Loss_TopK10.py │ │ │ │ ├── nnUNetTrainerV2_focalLoss.py │ │ │ │ └── nnUNetTrainerV2_graduallyTransitionFromCEToDice.py │ │ │ │ ├── miscellaneous │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ │ └── nnUNetTrainerV2_fullEvals.cpython-37.pyc │ │ │ │ └── nnUNetTrainerV2_fullEvals.py │ │ │ │ ├── nnUNetTrainerCE.py │ │ │ │ ├── nnUNetTrainerNoDA.py │ │ │ │ ├── optimizer_and_lr │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Adam.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Adam_ReduceOnPlateau.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Adam_lr_3en4.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_O2.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Ranger_lr1en2.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Ranger_lr3en3.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_Ranger_lr3en4.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_SGD_ReduceOnPlateau.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_SGD_fixedSchedule.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_SGD_fixedSchedule2.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_SGD_lrs.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_cycleAtEnd.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_fp16.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_momentum09.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_momentum095.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_momentum098.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_momentum09in2D.cpython-37.pyc │ │ │ │ │ ├── nnUNetTrainerV2_reduceMomentumDuringTraining.cpython-37.pyc │ │ │ │ │ └── nnUNetTrainerV2_warmup.cpython-37.pyc │ │ │ │ ├── nnUNetTrainerV2_Adam.py │ │ │ │ ├── nnUNetTrainerV2_Adam_ReduceOnPlateau.py │ │ │ │ ├── nnUNetTrainerV2_Adam_lr_3en4.py │ │ │ │ ├── nnUNetTrainerV2_O2.py │ │ │ │ ├── nnUNetTrainerV2_Ranger_lr1en2.py │ │ │ │ ├── nnUNetTrainerV2_Ranger_lr3en3.py │ │ │ │ ├── nnUNetTrainerV2_Ranger_lr3en4.py │ │ │ │ ├── nnUNetTrainerV2_SGD_ReduceOnPlateau.py │ │ │ │ ├── nnUNetTrainerV2_SGD_fixedSchedule.py │ │ │ │ ├── nnUNetTrainerV2_SGD_fixedSchedule2.py │ │ │ │ ├── nnUNetTrainerV2_SGD_lrs.py │ │ │ │ ├── nnUNetTrainerV2_cycleAtEnd.py │ │ │ │ ├── nnUNetTrainerV2_fp16.py │ │ │ │ ├── nnUNetTrainerV2_momentum09.py │ │ │ │ ├── nnUNetTrainerV2_momentum095.py │ │ │ │ ├── nnUNetTrainerV2_momentum098.py │ │ │ │ ├── nnUNetTrainerV2_momentum09in2D.py │ │ │ │ ├── nnUNetTrainerV2_reduceMomentumDuringTraining.py │ │ │ │ └── nnUNetTrainerV2_warmup.py │ │ │ │ ├── profiling │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ │ └── nnUNetTrainerV2_2epochs.cpython-37.pyc │ │ │ │ └── nnUNetTrainerV2_2epochs.py │ │ │ │ └── resampling │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ └── nnUNetTrainerV2_resample33.cpython-37.pyc │ │ │ │ └── nnUNetTrainerV2_resample33.py │ │ └── optimizer │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ └── ranger.cpython-37.pyc │ │ │ └── ranger.py │ └── utilities │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── distributed.cpython-37.pyc │ │ ├── file_endings.cpython-37.pyc │ │ ├── nd_softmax.cpython-37.pyc │ │ ├── one_hot_encoding.cpython-37.pyc │ │ ├── sitk_stuff.cpython-37.pyc │ │ ├── task_name_id_conversion.cpython-37.pyc │ │ ├── tensor_utilities.cpython-37.pyc │ │ └── to_torch.cpython-37.pyc │ │ ├── distributed.py │ │ ├── file_endings.py │ │ ├── folder_names.py │ │ ├── nd_softmax.py │ │ ├── one_hot_encoding.py │ │ ├── recursive_delete_npz.py │ │ ├── recursive_rename_taskXX_to_taskXXX.py │ │ ├── sitk_stuff.py │ │ ├── task_name_id_conversion.py │ │ ├── tensor_utilities.py │ │ └── to_torch.py ├── readme.md ├── setup.cfg ├── setup.py └── tests │ └── test_steps_for_sliding_window_prediction.py ├── output └── aneurysms.nii.gz └── seg_initial └── aneurysms.nii.gz /ADAM_Postprocess.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Aug 14 16:11:38 2020 4 | 5 | @author: MA 6 | """ 7 | 8 | import os 9 | join = os.path.join 10 | import argparse 11 | import nibabel as nib 12 | import numpy as np 13 | import shutil 14 | 15 | def main(): 16 | parser = argparse.ArgumentParser() 17 | parser.add_argument("--input_path", default="./seg_initial", help="input path") 18 | parser.add_argument("--save_path", required=False, help="save path") 19 | args = parser.parse_args() 20 | 21 | input_path = args.input_path 22 | save_path = args.save_path 23 | if os.path.exists(save_path) is False: 24 | os.mkdir(save_path) 25 | 26 | 27 | 28 | 29 | nii = nib.load(join(input_path, 'TOF.nii.gz')) 30 | seg = nii.get_fdata() 31 | num_voxels = np.sum(seg) 32 | print(" voxels:", np.sum(seg)) 33 | if num_voxels<11: 34 | new_seg = np.zeros_like(seg) 35 | nib.save(nib.Nifti1Image(new_seg, nii.affine, nii.header), join(save_path, 'output.nii.gz')) 36 | 37 | else: 38 | shutil.copyfile(join(input_path, 'TOF.nii.gz'), join(save_path, 'output.nii.gz')) 39 | 40 | if __name__ == "__main__": 41 | main() -------------------------------------------------------------------------------- /ADAM_Preprocess.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Aug 14 16:11:38 2020 4 | 5 | @author: MA 6 | """ 7 | 8 | import os 9 | join = os.path.join 10 | import argparse 11 | import shutil 12 | 13 | def main(): 14 | parser = argparse.ArgumentParser() 15 | parser.add_argument("--input_path", required=False, help="input path") 16 | parser.add_argument("--save_path", default="./input_preprocess", help="save path") 17 | args = parser.parse_args() 18 | 19 | input_path = args.input_path 20 | save_path = args.save_path 21 | 22 | if os.path.exists(save_path) is False: 23 | os.mkdir(save_path) 24 | 25 | 26 | 27 | shutil.copyfile(join(join(input_path, "pre"),"TOF.nii.gz"), join(save_path, 'TOF_0000.nii.gz')) 28 | print(" preprocess finished!") 29 | 30 | if __name__ == "__main__": 31 | main() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | > 1st Place Solution to MICCAI 2020 ADAM Challenge in Segmentation Task. 4 | 5 | ## Step 1. Prepare input data and running environment 6 | 7 | Put input data into the folder `input`. The folder structure should be 8 | 9 | ```python 10 | input 11 | ——10001 12 | ————orig 13 | ——————struct.nii.gz 14 | ——————... 15 | ————pre 16 | ——————TOF.nii.gz # we only use the preprocessed TOF data 17 | ——————... 18 | ``` 19 | 20 | Run 21 | 22 | > python 3.7.6; pytorch 1.5.0; cuda 10.1 23 | 24 | ```python 25 | cd nnUNet 26 | pip install -e . 27 | cd .. 28 | # preprocess 29 | python ADAM_Preprocess.py --input_path ./input 30 | cd nnUNet/nnunet 31 | ``` 32 | 33 | ## Step 2. Inference 34 | 35 | Download the trained models: [link](https://pan.baidu.com/s/176J6mS8dx89Nbht5EaeYEg ) (PW: b9oo), and put it in the `ADAM2020/nnUNet/nnunet/TrainedModels/nnUNet/3d_fullres` 36 | 37 | Run 38 | 39 | ```python 40 | nnUNet_predict -i ../../input_preprocess -o ../../seg_initial -m 3d_fullres -t Task600_ADAM --disable_tta 41 | cd ../../ 42 | ``` 43 | 44 | ```python 45 | # postprocess 46 | python ADAM_Postprocess.py --save_path ./output 47 | ``` 48 | 49 | The final segmentation results are in the folder `output`. 50 | 51 | -------------------------------------------------------------------------------- /input/10040/aneurysms.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/input/10040/aneurysms.nii.gz -------------------------------------------------------------------------------- /input/10040/location.txt: -------------------------------------------------------------------------------- 1 | 304, 242, 51, 1.24 -------------------------------------------------------------------------------- /nnUNet/documentation/data_format_inference.md: -------------------------------------------------------------------------------- 1 | # Data format for Inference 2 | 3 | The data format for inference must match the one used for the raw data (specifically, the images must be in exactly 4 | the same format as in the imagesTr folder). As before, the filenames must start with a 5 | unique identifier, followed by a 4-digit modality identifier. Here is an example for two different datasets: 6 | 7 | 1) Task005_Prostate: 8 | 9 | This task has 2 modalities, so the files in the input folder must look like this: 10 | 11 | input_folder 12 | ├── prostate_03_0000.nii.gz 13 | ├── prostate_03_0001.nii.gz 14 | ├── prostate_05_0000.nii.gz 15 | ├── prostate_05_0001.nii.gz 16 | ├── prostate_08_0000.nii.gz 17 | ├── prostate_08_0001.nii.gz 18 | ├── ... 19 | 20 | _0000 is always the T2 image and _0001 is always the ADC image (as specified by 'modality' in the dataset.json) 21 | 22 | 2) Task002_Heart: 23 | 24 | imagesTs 25 | ├── la_001_0000.nii.gz 26 | ├── la_002_0000.nii.gz 27 | ├── la_006_0000.nii.gz 28 | ├── ... 29 | 30 | Task002 only has one modality, so each case only has one _0000.nii.gz file. 31 | 32 | 33 | The segmentations in the output folder will be named INDENTIFIER.nii.gz (omitting the modality identifier). 34 | -------------------------------------------------------------------------------- /nnUNet/documentation/training_example_Hippocampus.md: -------------------------------------------------------------------------------- 1 | # Example: 3D U-Net training on the Hippocampus dataset 2 | 3 | This is a step-by-step example on how to run a 3D full resolution Training with the Hippocampus dataset from the 4 | Medical Segmentation Decathlon. 5 | 6 | 1) Install nnU-Net by following the instructions [here](../readme.md#installation). Make sure to set all relevant paths, 7 | also see [here](setting_up_paths.md). This step is necessary so that nnU-Net knows where to store raw data, 8 | preprocessed data and trained models. 9 | 2) Download the Hippocampus dataset of the Medical Segmentation Decathlon from 10 | [here](https://drive.google.com/drive/folders/1HqEgzS8BV2c7xYNrZdEAnrHk7osJJ--2). Then extract the archive to a 11 | destination of your choice. 12 | 3) Decathlon data come as 4D niftis. This is not compatible with nnU-Net (see dataset format specified 13 | [here](dataset_conversion.md)). Convert the Hippocampus dataset into the correct format with 14 | 15 | ```bash 16 | nnUNet_convert_decathlon_task -i /xxx/Task04_Hippocampus 17 | ``` 18 | 19 | Note that `Task04_Hippocampus` must be the folder that has the three 'imagesTr', 'labelsTr', 'imagesTs' subfolders! 20 | The converted dataset can be found in $nnUNet_raw_data_base/nnUNet_raw_data ($nnUNet_raw_data_base is the folder for 21 | raw data that you specified during installation) 22 | 4) You can now run nnU-Nets pipeline configuration (and the preprocessing) with the following line: 23 | ```bash 24 | nnUNet_plan_and_preprocess -t 4 25 | ``` 26 | Where 4 refers to the task ID of the Hippocampus dataset. 27 | 5) Now you can already start network training. This is how you train a 3d full resoltion U-Net on the Hippocampus dataset: 28 | ```bash 29 | nnUNet_train 3d_fullres nnUNetTrainerV2 4 0 30 | ``` 31 | nnU-Net per default requires all trainings as 5-fold cross validation. The command above will run only the training for the 32 | first fold (fold 0). 4 is the task identifier of the hippocampus dataset. Training one fold should take about 20 33 | hours on a modern GPU. 34 | 35 | This tutorial is only intended to demonstrate how easy it is to get nnU-Net running. You do not need to finish the 36 | network training - pretrained models for the hippocampus task are available (see [here](../readme.md#run-inference)). 37 | 38 | The only prerequisite for running nnU-Net on your custom dataset is to bring it into a structured, nnU-Net compatible 39 | format. nnU-Net will take care of the rest. See [here](dataset_conversion.md) for instructions on how to convert 40 | datasets into nnU-Net compatible format. 41 | -------------------------------------------------------------------------------- /nnUNet/nnunet/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | print("\nPlease cite the following paper when using nnUNet:\nFabian Isensee, Paul F. Jäger, Simon A. A. Kohl, " 3 | "Jens Petersen, Klaus H. Maier-Hein \"Automated Design of Deep Learning Methods for Biomedical Image " 4 | "Segmentation\" arXiv preprint arXiv:1904.08128 (2020).") 5 | print("If you have questions or suggestions, feel free to open an issue at https://github.com/MIC-DKFZ/nnUNet\n") 6 | 7 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/__pycache__/configuration.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/__pycache__/configuration.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/__pycache__/paths.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/__pycache__/paths.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/configuration.py: -------------------------------------------------------------------------------- 1 | default_num_threads = 8 2 | RESAMPLING_SEPARATE_Z_ANISO_THRESHOLD = 3 # determines what threshold to use for resampling the low resolution axis 3 | # separately (with NN) -------------------------------------------------------------------------------- /nnUNet/nnunet/dataset_conversion/Task017_BeyondCranialVaultAbdominalOrganSegmentation.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from batchgenerators.utilities.file_and_folder_operations import * 16 | import shutil 17 | 18 | 19 | if __name__ == "__main__": 20 | indir = "/home/fabian/drives/datasets/results/nnUNet/test_sets/Task017_AbdominalOrganSegmentation/predicted_3d_cascade_fullres" 21 | outdir = "/home/fabian/drives/datasets/results/nnUNet/test_sets/Task017_AbdominalOrganSegmentation/ready_for_submission" 22 | files = subfiles(indir, suffix='nii.gz', prefix="img", join=False) 23 | maybe_mkdir_p(outdir) 24 | for f in files: 25 | outname = "label" + f[3:] 26 | shutil.copy(join(indir, f), join(outdir, outname)) 27 | -------------------------------------------------------------------------------- /nnUNet/nnunet/dataset_conversion/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/evaluation/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/evaluation/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/evaluation/__pycache__/evaluator.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/evaluation/__pycache__/evaluator.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/evaluation/__pycache__/metrics.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/evaluation/__pycache__/metrics.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/evaluation/__pycache__/region_based_evaluation.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/evaluation/__pycache__/region_based_evaluation.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/evaluation/add_mean_dice_to_json.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import json 16 | import numpy as np 17 | from batchgenerators.utilities.file_and_folder_operations import subfiles 18 | from collections import OrderedDict 19 | 20 | 21 | def foreground_mean(filename): 22 | with open(filename, 'r') as f: 23 | res = json.load(f) 24 | class_ids = np.array([int(i) for i in res['results']['mean'].keys() if (i != 'mean')]) 25 | class_ids = class_ids[class_ids != 0] 26 | class_ids = class_ids[class_ids != -1] 27 | class_ids = class_ids[class_ids != 99] 28 | 29 | tmp = res['results']['mean'].get('99') 30 | if tmp is not None: 31 | _ = res['results']['mean'].pop('99') 32 | 33 | metrics = res['results']['mean']['1'].keys() 34 | res['results']['mean']["mean"] = OrderedDict() 35 | for m in metrics: 36 | foreground_values = [res['results']['mean'][str(i)][m] for i in class_ids] 37 | res['results']['mean']["mean"][m] = np.nanmean(foreground_values) 38 | with open(filename, 'w') as f: 39 | json.dump(res, f, indent=4, sort_keys=True) 40 | 41 | 42 | def run_in_folder(folder): 43 | json_files = subfiles(folder, True, None, ".json", True) 44 | json_files = [i for i in json_files if not i.split("/")[-1].startswith(".") and not i.endswith("_globalMean.json")] # stupid mac 45 | for j in json_files: 46 | foreground_mean(j) 47 | 48 | 49 | if __name__ == "__main__": 50 | folder = "/media/fabian/Results/nnUNetOutput_final/summary_jsons" 51 | run_in_folder(folder) 52 | -------------------------------------------------------------------------------- /nnUNet/nnunet/evaluation/collect_results_files.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import os 16 | import shutil 17 | from batchgenerators.utilities.file_and_folder_operations import subdirs, subfiles 18 | 19 | 20 | def crawl_and_copy(current_folder, out_folder, prefix="fabian_", suffix="ummary.json"): 21 | """ 22 | This script will run recursively through all subfolders of current_folder and copy all files that end with 23 | suffix with some automatically generated prefix into out_folder 24 | :param current_folder: 25 | :param out_folder: 26 | :param prefix: 27 | :return: 28 | """ 29 | s = subdirs(current_folder, join=False) 30 | f = subfiles(current_folder, join=False) 31 | f = [i for i in f if i.endswith(suffix)] 32 | if current_folder.find("fold0") != -1: 33 | for fl in f: 34 | shutil.copy(os.path.join(current_folder, fl), os.path.join(out_folder, prefix+fl)) 35 | for su in s: 36 | if prefix == "": 37 | add = su 38 | else: 39 | add = "__" + su 40 | crawl_and_copy(os.path.join(current_folder, su), out_folder, prefix=prefix+add) 41 | 42 | 43 | if __name__ == "__main__": 44 | from nnunet.paths import network_training_output_dir 45 | output_folder = "/home/fabian/PhD/results/nnUNetV2/leaderboard" 46 | crawl_and_copy(network_training_output_dir, output_folder) 47 | from nnunet.evaluation.add_mean_dice_to_json import run_in_folder 48 | run_in_folder(output_folder) 49 | -------------------------------------------------------------------------------- /nnUNet/nnunet/evaluation/model_selection/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/DatasetAnalyzer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/DatasetAnalyzer.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/common_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/common_utils.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/experiment_planner_baseline_2DUNet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/experiment_planner_baseline_2DUNet.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/experiment_planner_baseline_2DUNet_v21.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/experiment_planner_baseline_2DUNet_v21.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/experiment_planner_baseline_3DUNet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/experiment_planner_baseline_3DUNet.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v21.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v21.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/nnUNet_convert_decathlon_task.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/nnUNet_convert_decathlon_task.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/nnUNet_plan_and_preprocess.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/nnUNet_plan_and_preprocess.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/summarize_plans.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/summarize_plans.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/__pycache__/utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/__pycache__/utils.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v21_11GB.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v21_11GB.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v21_32GB.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v21_32GB.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v21_3convperstage.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v21_3convperstage.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v22.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v22.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v23.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_baseline_3DUNet_v23.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_residual_3DUNet_v21.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/__pycache__/experiment_planner_residual_3DUNet_v21.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/experiment_planner_baseline_3DUNet_v21_3convperstage.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from copy import deepcopy 16 | 17 | import numpy as np 18 | from nnunet.experiment_planning.common_utils import get_pool_and_conv_props 19 | from nnunet.experiment_planning.experiment_planner_baseline_3DUNet import ExperimentPlanner 20 | from nnunet.experiment_planning.experiment_planner_baseline_3DUNet_v21 import ExperimentPlanner3D_v21 21 | from nnunet.network_architecture.generic_UNet import Generic_UNet 22 | from nnunet.paths import * 23 | 24 | 25 | class ExperimentPlanner3D_v21_3cps(ExperimentPlanner3D_v21): 26 | """ 27 | have 3x conv-in-lrelu per resolution instead of 2 while remaining in the same memory budget 28 | 29 | This only works with 3d fullres because we use the same data as ExperimentPlanner3D_v21. Lowres would require to 30 | rerun preprocesing (different patch size = different 3d lowres target spacing) 31 | """ 32 | def __init__(self, folder_with_cropped_data, preprocessed_output_folder): 33 | super(ExperimentPlanner3D_v21_3cps, self).__init__(folder_with_cropped_data, preprocessed_output_folder) 34 | self.plans_fname = join(self.preprocessed_output_folder, 35 | "nnUNetPlansv2.1_3cps_plans_3D.pkl") 36 | self.unet_base_num_features = 32 37 | self.conv_per_stage = 3 38 | 39 | def run_preprocessing(self, num_threads): 40 | pass 41 | -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/experiment_planner_baseline_3DUNet_v23.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from nnunet.experiment_planning.experiment_planner_baseline_3DUNet_v21 import \ 16 | ExperimentPlanner3D_v21 17 | from nnunet.paths import * 18 | 19 | 20 | class ExperimentPlanner3D_v23(ExperimentPlanner3D_v21): 21 | """ 22 | """ 23 | def __init__(self, folder_with_cropped_data, preprocessed_output_folder): 24 | super(ExperimentPlanner3D_v23, self).__init__(folder_with_cropped_data, preprocessed_output_folder) 25 | self.data_identifier = "nnUNetData_plans_v2.3" 26 | self.plans_fname = join(self.preprocessed_output_folder, 27 | "nnUNetPlansv2.3_plans_3D.pkl") 28 | self.preprocessor_name = "Preprocessor3DDifferentResampling" 29 | -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/normalization/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/normalization/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/normalization/experiment_planner_3DUNet_CT2.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from collections import OrderedDict 17 | 18 | from nnunet.experiment_planning.experiment_planner_baseline_3DUNet import ExperimentPlanner 19 | from nnunet.paths import * 20 | 21 | 22 | class ExperimentPlannerCT2(ExperimentPlanner): 23 | """ 24 | preprocesses CT data with the "CT2" normalization. 25 | 26 | (clip range comes from training set and is the 0.5 and 99.5 percentile of intensities in foreground) 27 | CT = clip to range, then normalize with global mn and sd (computed on foreground in training set) 28 | CT2 = clip to range, normalize each case separately with its own mn and std (computed within the area that was in clip_range) 29 | """ 30 | def __init__(self, folder_with_cropped_data, preprocessed_output_folder): 31 | super(ExperimentPlannerCT2, self).__init__(folder_with_cropped_data, preprocessed_output_folder) 32 | self.data_identifier = "nnUNet_CT2" 33 | self.plans_fname = join(self.preprocessed_output_folder, "nnUNetPlans" + "CT2_plans_3D.pkl") 34 | 35 | def determine_normalization_scheme(self): 36 | schemes = OrderedDict() 37 | modalities = self.dataset_properties['modalities'] 38 | num_modalities = len(list(modalities.keys())) 39 | 40 | for i in range(num_modalities): 41 | if modalities[i] == "CT": 42 | schemes[i] = "CT2" 43 | else: 44 | schemes[i] = "nonCT" 45 | return schemes 46 | -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/normalization/experiment_planner_3DUNet_nonCT.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from collections import OrderedDict 17 | 18 | from nnunet.experiment_planning.experiment_planner_baseline_3DUNet import ExperimentPlanner 19 | from nnunet.paths import * 20 | 21 | 22 | class ExperimentPlannernonCT(ExperimentPlanner): 23 | """ 24 | Preprocesses all data in nonCT mode (this is what we use for MRI per default, but here it is applied to CT images 25 | as well) 26 | """ 27 | def __init__(self, folder_with_cropped_data, preprocessed_output_folder): 28 | super(ExperimentPlannernonCT, self).__init__(folder_with_cropped_data, preprocessed_output_folder) 29 | self.data_identifier = "nnUNet_nonCT" 30 | self.plans_fname = join(self.preprocessed_output_folder, "nnUNetPlans" + "nonCT_plans_3D.pkl") 31 | 32 | def determine_normalization_scheme(self): 33 | schemes = OrderedDict() 34 | modalities = self.dataset_properties['modalities'] 35 | num_modalities = len(list(modalities.keys())) 36 | 37 | for i in range(num_modalities): 38 | if modalities[i] == "CT": 39 | schemes[i] = "nonCT" 40 | else: 41 | schemes[i] = "nonCT" 42 | return schemes 43 | 44 | -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/patch_size/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/patch_size/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/pooling_and_convs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/pooling_and_convs/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/readme.md: -------------------------------------------------------------------------------- 1 | These alternatives are not used in nnU-Net, but you can use them if you believe they might be better suited for you. 2 | I (Fabian) have not found them to be consistently superior. -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/alternative_experiment_planning/target_spacing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/alternative_experiment_planning/target_spacing/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/experiment_planning/old/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/experiment_planning/old/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/inference/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/inference/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/inference/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/inference/__pycache__/predict.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/inference/__pycache__/predict.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/inference/__pycache__/predict_simple.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/inference/__pycache__/predict_simple.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/inference/__pycache__/segmentation_export.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/inference/__pycache__/segmentation_export.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/inference/pretrained_models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/inference/pretrained_models/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/__pycache__/generic_UNet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/__pycache__/generic_UNet.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/__pycache__/generic_UNet_DP.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/__pycache__/generic_UNet_DP.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/__pycache__/generic_modular_UNet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/__pycache__/generic_modular_UNet.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/__pycache__/generic_modular_residual_UNet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/__pycache__/generic_modular_residual_UNet.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/__pycache__/initialization.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/__pycache__/initialization.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/__pycache__/neural_network.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/__pycache__/neural_network.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/custom_modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/custom_modules/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/custom_modules/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/custom_modules/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/custom_modules/__pycache__/conv_blocks.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/custom_modules/__pycache__/conv_blocks.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/custom_modules/__pycache__/feature_response_normalization.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/custom_modules/__pycache__/feature_response_normalization.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/custom_modules/__pycache__/helperModules.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/custom_modules/__pycache__/helperModules.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/custom_modules/__pycache__/mish.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/network_architecture/custom_modules/__pycache__/mish.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/custom_modules/feature_response_normalization.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.utilities.tensor_utilities import mean_tensor 17 | from torch import nn 18 | import torch 19 | from torch.nn.parameter import Parameter 20 | import torch.jit 21 | 22 | 23 | class FRN3D(nn.Module): 24 | def __init__(self, num_features: int, eps=1e-6, **kwargs): 25 | super().__init__() 26 | self.eps = eps 27 | self.num_features = num_features 28 | self.weight = Parameter(torch.ones(1, num_features, 1, 1, 1), True) 29 | self.bias = Parameter(torch.zeros(1, num_features, 1, 1, 1), True) 30 | self.tau = Parameter(torch.zeros(1, num_features, 1, 1, 1), True) 31 | 32 | def forward(self, x: torch.Tensor): 33 | x = x * torch.rsqrt(mean_tensor(x * x, [2, 3, 4], keepdim=True) + self.eps) 34 | 35 | return torch.max(self.weight * x + self.bias, self.tau) 36 | 37 | 38 | if __name__ == "__main__": 39 | tmp = torch.rand((3, 32, 16, 16, 16)) 40 | 41 | frn = FRN3D(32) 42 | 43 | out = frn(tmp) 44 | -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/custom_modules/helperModules.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from torch import nn 17 | 18 | 19 | class Identity(nn.Module): 20 | def __init__(self, *args, **kwargs): 21 | super().__init__() 22 | 23 | def forward(self, input): 24 | return input 25 | 26 | 27 | class MyGroupNorm(nn.GroupNorm): 28 | def __init__(self, num_channels, eps=1e-5, affine=True, num_groups=8): 29 | super(MyGroupNorm, self).__init__(num_groups, num_channels, eps, affine) 30 | -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/custom_modules/mish.py: -------------------------------------------------------------------------------- 1 | ############ 2 | # https://github.com/lessw2020/mish/blob/master/mish.py 3 | # This code was taken from the repo above and was not created by me (Fabian)! Full credit goes to the original authors 4 | ############ 5 | 6 | import torch 7 | 8 | import torch.nn as nn 9 | import torch.nn.functional as F 10 | 11 | 12 | # Mish - "Mish: A Self Regularized Non-Monotonic Neural Activation Function" 13 | # https://arxiv.org/abs/1908.08681v1 14 | # implemented for PyTorch / FastAI by lessw2020 15 | # github: https://github.com/lessw2020/mish 16 | 17 | class Mish(nn.Module): 18 | def __init__(self): 19 | super().__init__() 20 | 21 | def forward(self, x): 22 | # inlining this saves 1 second per epoch (V100 GPU) vs having a temp x and then returning x(!) 23 | return x * (torch.tanh(F.softplus(x))) 24 | -------------------------------------------------------------------------------- /nnUNet/nnunet/network_architecture/initialization.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from torch import nn 17 | 18 | 19 | class InitWeights_He(object): 20 | def __init__(self, neg_slope=1e-2): 21 | self.neg_slope = neg_slope 22 | 23 | def __call__(self, module): 24 | if isinstance(module, nn.Conv3d) or isinstance(module, nn.Conv2d) or isinstance(module, nn.ConvTranspose2d) or isinstance(module, nn.ConvTranspose3d): 25 | module.weight = nn.init.kaiming_normal_(module.weight, a=self.neg_slope) 26 | if module.bias is not None: 27 | module.bias = nn.init.constant_(module.bias, 0) 28 | 29 | 30 | class InitWeights_XavierUniform(object): 31 | def __init__(self, gain=1): 32 | self.gain = gain 33 | 34 | def __call__(self, module): 35 | if isinstance(module, nn.Conv3d) or isinstance(module, nn.Conv2d) or isinstance(module, nn.ConvTranspose2d) or isinstance(module, nn.ConvTranspose3d): 36 | module.weight = nn.init.xavier_uniform_(module.weight, self.gain) 37 | if module.bias is not None: 38 | module.bias = nn.init.constant_(module.bias, 0) 39 | -------------------------------------------------------------------------------- /nnUNet/nnunet/postprocessing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/postprocessing/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/postprocessing/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/postprocessing/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/postprocessing/__pycache__/connected_components.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/postprocessing/__pycache__/connected_components.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/postprocessing/__pycache__/consolidate_postprocessing.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/postprocessing/__pycache__/consolidate_postprocessing.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/preprocessing/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/preprocessing/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/preprocessing/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/preprocessing/__pycache__/cropping.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/preprocessing/__pycache__/cropping.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/preprocessing/__pycache__/preprocessing.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/preprocessing/__pycache__/preprocessing.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/preprocessing/__pycache__/sanity_checks.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/preprocessing/__pycache__/sanity_checks.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/run/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/run/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/run/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/run/__pycache__/default_configuration.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/run/__pycache__/default_configuration.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/run/__pycache__/run_training.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/run/__pycache__/run_training.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/training/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/__pycache__/model_restore.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/__pycache__/model_restore.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/cascade_stuff/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/training/cascade_stuff/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/cascade_stuff/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/cascade_stuff/__pycache__/predict_next_stage.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/cascade_stuff/__pycache__/predict_next_stage.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/data_augmentation/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/training/data_augmentation/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/data_augmentation/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/data_augmentation/__pycache__/custom_transforms.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/data_augmentation/__pycache__/custom_transforms.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/data_augmentation/__pycache__/default_data_augmentation.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/data_augmentation/__pycache__/default_data_augmentation.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/data_augmentation/__pycache__/downsampling.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/data_augmentation/__pycache__/downsampling.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/data_augmentation/__pycache__/pyramid_augmentations.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/data_augmentation/__pycache__/pyramid_augmentations.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/dataloading/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/training/dataloading/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/dataloading/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/dataloading/__pycache__/dataset_loading.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/dataloading/__pycache__/dataset_loading.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/learning_rate/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/learning_rate/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/learning_rate/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/learning_rate/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/learning_rate/__pycache__/poly_lr.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/learning_rate/__pycache__/poly_lr.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/learning_rate/poly_lr.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | def poly_lr(epoch, max_epochs, initial_lr, exponent=0.9): 17 | return initial_lr * (1 - epoch / max_epochs)**exponent 18 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/loss_functions/ND_Crossentropy.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch.nn 16 | 17 | 18 | class CrossentropyND(torch.nn.CrossEntropyLoss): 19 | """ 20 | Network has to have NO NONLINEARITY! 21 | """ 22 | def forward(self, inp, target): 23 | target = target.long() 24 | num_classes = inp.size()[1] 25 | 26 | i0 = 1 27 | i1 = 2 28 | 29 | while i1 < len(inp.shape): # this is ugly but torch only allows to transpose two axes at once 30 | inp = inp.transpose(i0, i1) 31 | i0 += 1 32 | i1 += 1 33 | 34 | inp = inp.contiguous() 35 | inp = inp.view(-1, num_classes) 36 | 37 | target = target.view(-1,) 38 | 39 | return super(CrossentropyND, self).forward(inp, target) 40 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/loss_functions/TopK_loss.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import numpy as np 16 | import torch 17 | from nnunet.training.loss_functions.ND_Crossentropy import CrossentropyND 18 | 19 | 20 | class TopKLoss(CrossentropyND): 21 | """ 22 | Network has to have NO LINEARITY! 23 | """ 24 | def __init__(self, weight=None, ignore_index=-100, k=10): 25 | self.k = k 26 | super(TopKLoss, self).__init__(weight, False, ignore_index, reduce=False) 27 | 28 | def forward(self, inp, target): 29 | target = target[:, 0].long() 30 | res = super(TopKLoss, self).forward(inp, target) 31 | num_voxels = np.prod(res.shape, dtype=np.int64) 32 | res, _ = torch.topk(res.view((-1, )), int(num_voxels * self.k / 100), sorted=False) 33 | return res.mean() 34 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/loss_functions/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/training/loss_functions/__pycache__/ND_Crossentropy.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/loss_functions/__pycache__/ND_Crossentropy.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/loss_functions/__pycache__/TopK_loss.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/loss_functions/__pycache__/TopK_loss.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/loss_functions/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/loss_functions/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/loss_functions/__pycache__/deep_supervision.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/loss_functions/__pycache__/deep_supervision.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/loss_functions/__pycache__/dice_loss.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/loss_functions/__pycache__/dice_loss.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/loss_functions/deep_supervision.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from torch import nn 17 | 18 | 19 | class MultipleOutputLoss2(nn.Module): 20 | def __init__(self, loss, weight_factors=None): 21 | """ 22 | use this if you have several outputs and ground truth (both list of same len) and the loss should be computed 23 | between them (x[0] and y[0], x[1] and y[1] etc) 24 | :param loss: 25 | :param weight_factors: 26 | """ 27 | super(MultipleOutputLoss2, self).__init__() 28 | self.weight_factors = weight_factors 29 | self.loss = loss 30 | 31 | def forward(self, x, y): 32 | assert isinstance(x, (tuple, list)), "x must be either tuple or list" 33 | assert isinstance(y, (tuple, list)), "y must be either tuple or list" 34 | if self.weight_factors is None: 35 | weights = [1] * len(x) 36 | else: 37 | weights = self.weight_factors 38 | 39 | l = weights[0] * self.loss(x[0], y[0]) 40 | for i in range(1, len(x)): 41 | if weights[i] != 0: 42 | l += weights[i] * self.loss(x[i], y[i]) 43 | return l 44 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/network_trainer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/network_trainer.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainer.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerCascadeFullRes.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerCascadeFullRes.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_CascadeFullRes.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_CascadeFullRes.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_DDP.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_DDP.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_DP.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_DP.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_Loss_Dice.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_Loss_Dice.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_Loss_DiceTopK10.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_Loss_DiceTopK10.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_fp32.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/__pycache__/nnUNetTrainerV2_fp32.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNetTrainerV2_Loss_Dice.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.loss_functions.dice_loss import SoftDiceLoss 18 | from nnunet.utilities.nd_softmax import softmax_helper 19 | 20 | 21 | class nnUNetTrainerV2_Loss_Dice(nnUNetTrainerV2): 22 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 23 | unpack_data=True, deterministic=True, fp16=False): 24 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 25 | deterministic, fp16) 26 | self.loss = SoftDiceLoss(**{'apply_nonlin': softmax_helper, 'batch_dice': self.batch_dice, 'smooth': 1e-5, 'do_bg': False}) 27 | 28 | 29 | class nnUNetTrainerV2_Loss_DicewithBG(nnUNetTrainerV2): 30 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 31 | unpack_data=True, deterministic=True, fp16=False): 32 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 33 | deterministic, fp16) 34 | self.loss = SoftDiceLoss(**{'apply_nonlin': softmax_helper, 'batch_dice': self.batch_dice, 'smooth': 1e-5, 'do_bg': True}) 35 | 36 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNetTrainerV2_Loss_DiceTopK10.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.loss_functions.dice_loss import DC_and_topk_loss 18 | 19 | 20 | class nnUNetTrainerV2_Loss_DiceTopK10(nnUNetTrainerV2): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | self.loss = DC_and_topk_loss({'batch_dice': self.batch_dice, 'smooth': 1e-5, 'do_bg': False}, 26 | {'k': 10}) 27 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNetTrainerV2_fp32.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | 18 | 19 | class nnUNetTrainerV2_fp32(nnUNetTrainerV2): 20 | """ 21 | Info for Fabian: same as internal nnUNetTrainerV2_2 22 | """ 23 | 24 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 25 | unpack_data=True, deterministic=True, fp16=False): 26 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 27 | deterministic, False) 28 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/__pycache__/nnUNetTrainerCE.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/__pycache__/nnUNetTrainerCE.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/__pycache__/nnUNetTrainerNoDA.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/__pycache__/nnUNetTrainerNoDA.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_3ConvPerStage.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_3ConvPerStage.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_3ConvPerStage_samefilters.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_3ConvPerStage_samefilters.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_BN.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_BN.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_FRN.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_FRN.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_GN.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_GN.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_GeLU.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_GeLU.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_LReLU_slope_2en1.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_LReLU_slope_2en1.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_Mish.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_Mish.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_NoNormalization.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_NoNormalization.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_NoNormalization_lr1en3.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_NoNormalization_lr1en3.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_ReLU.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_ReLU.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_ReLU_biasInSegOutput.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_ReLU_biasInSegOutput.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_ReLU_convReLUIN.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_ReLU_convReLUIN.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_ResencUNet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_ResencUNet.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_allConv3x3.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_allConv3x3.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_lReLU_biasInSegOutput.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_lReLU_biasInSegOutput.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_lReLU_convlReLUIN.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_lReLU_convlReLUIN.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_noDeepSupervision.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_noDeepSupervision.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_softDeepSupervision.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/__pycache__/nnUNetTrainerV2_softDeepSupervision.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_3ConvPerStage.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.generic_UNet import Generic_UNet 17 | from nnunet.network_architecture.initialization import InitWeights_He 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | from nnunet.utilities.nd_softmax import softmax_helper 20 | from torch import nn 21 | 22 | 23 | class nnUNetTrainerV2_3ConvPerStage(nnUNetTrainerV2): 24 | def initialize_network(self): 25 | self.base_num_features = 24 # otherwise we run out of VRAM 26 | if self.threeD: 27 | conv_op = nn.Conv3d 28 | dropout_op = nn.Dropout3d 29 | norm_op = nn.InstanceNorm3d 30 | 31 | else: 32 | conv_op = nn.Conv2d 33 | dropout_op = nn.Dropout2d 34 | norm_op = nn.InstanceNorm2d 35 | 36 | norm_op_kwargs = {'eps': 1e-5, 'affine': True} 37 | dropout_op_kwargs = {'p': 0, 'inplace': True} 38 | net_nonlin = nn.LeakyReLU 39 | net_nonlin_kwargs = {'negative_slope': 1e-2, 'inplace': True} 40 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 41 | len(self.net_num_pool_op_kernel_sizes), 42 | 3, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 43 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(1e-2), 44 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True) 45 | if torch.cuda.is_available(): 46 | self.network.cuda() 47 | self.network.inference_apply_nonlin = softmax_helper 48 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_3ConvPerStage_samefilters.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.generic_UNet import Generic_UNet 17 | from nnunet.network_architecture.initialization import InitWeights_He 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | from nnunet.utilities.nd_softmax import softmax_helper 20 | from torch import nn 21 | 22 | 23 | class nnUNetTrainerV2_3ConvPerStageSameFilters(nnUNetTrainerV2): 24 | def initialize_network(self): 25 | if self.threeD: 26 | conv_op = nn.Conv3d 27 | dropout_op = nn.Dropout3d 28 | norm_op = nn.InstanceNorm3d 29 | 30 | else: 31 | conv_op = nn.Conv2d 32 | dropout_op = nn.Dropout2d 33 | norm_op = nn.InstanceNorm2d 34 | 35 | norm_op_kwargs = {'eps': 1e-5, 'affine': True} 36 | dropout_op_kwargs = {'p': 0, 'inplace': True} 37 | net_nonlin = nn.LeakyReLU 38 | net_nonlin_kwargs = {'negative_slope': 1e-2, 'inplace': True} 39 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 40 | len(self.net_num_pool_op_kernel_sizes), 41 | 3, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 42 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(1e-2), 43 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True) 44 | if torch.cuda.is_available(): 45 | self.network.cuda() 46 | self.network.inference_apply_nonlin = softmax_helper 47 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_FRN.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.custom_modules.feature_response_normalization import FRN3D 17 | from nnunet.network_architecture.generic_UNet import Generic_UNet 18 | from nnunet.network_architecture.initialization import InitWeights_He 19 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 20 | from nnunet.utilities.nd_softmax import softmax_helper 21 | from torch import nn 22 | from nnunet.network_architecture.custom_modules.helperModules import Identity 23 | 24 | 25 | class nnUNetTrainerV2_FRN(nnUNetTrainerV2): 26 | def initialize_network(self): 27 | """ 28 | changed deep supervision to False 29 | :return: 30 | """ 31 | if self.threeD: 32 | conv_op = nn.Conv3d 33 | dropout_op = nn.Dropout3d 34 | norm_op = FRN3D 35 | 36 | else: 37 | conv_op = nn.Conv2d 38 | dropout_op = nn.Dropout2d 39 | raise NotImplementedError 40 | norm_op = nn.BatchNorm2d 41 | 42 | norm_op_kwargs = {'eps': 1e-6} 43 | dropout_op_kwargs = {'p': 0, 'inplace': True} 44 | net_nonlin = Identity 45 | net_nonlin_kwargs = {} 46 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 47 | len(self.net_num_pool_op_kernel_sizes), 48 | self.conv_per_stage, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 49 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(1e-2), 50 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True) 51 | if torch.cuda.is_available(): 52 | self.network.cuda() 53 | self.network.inference_apply_nonlin = softmax_helper 54 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_GN.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.generic_UNet import Generic_UNet 17 | from nnunet.network_architecture.initialization import InitWeights_He 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | from nnunet.network_architecture.custom_modules.helperModules import MyGroupNorm 20 | from nnunet.utilities.nd_softmax import softmax_helper 21 | from torch import nn 22 | 23 | 24 | class nnUNetTrainerV2_GN(nnUNetTrainerV2): 25 | def initialize_network(self): 26 | """ 27 | changed deep supervision to False 28 | :return: 29 | """ 30 | if self.threeD: 31 | conv_op = nn.Conv3d 32 | dropout_op = nn.Dropout3d 33 | norm_op = MyGroupNorm 34 | 35 | else: 36 | conv_op = nn.Conv2d 37 | dropout_op = nn.Dropout2d 38 | norm_op = MyGroupNorm 39 | 40 | norm_op_kwargs = {'eps': 1e-5, 'affine': True, 'num_groups': 8} 41 | dropout_op_kwargs = {'p': 0, 'inplace': True} 42 | net_nonlin = nn.LeakyReLU 43 | net_nonlin_kwargs = {'negative_slope': 1e-2, 'inplace': True} 44 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 45 | len(self.net_num_pool_op_kernel_sizes), 46 | self.conv_per_stage, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 47 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(1e-2), 48 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True) 49 | if torch.cuda.is_available(): 50 | self.network.cuda() 51 | self.network.inference_apply_nonlin = softmax_helper 52 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_LReLU_slope_2en1.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.generic_UNet import Generic_UNet 17 | from nnunet.network_architecture.initialization import InitWeights_He 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | from nnunet.utilities.nd_softmax import softmax_helper 20 | from torch import nn 21 | 22 | 23 | class nnUNetTrainerV2_LReLU_slope_2en1(nnUNetTrainerV2): 24 | def initialize_network(self): 25 | if self.threeD: 26 | conv_op = nn.Conv3d 27 | dropout_op = nn.Dropout3d 28 | norm_op = nn.InstanceNorm3d 29 | 30 | else: 31 | conv_op = nn.Conv2d 32 | dropout_op = nn.Dropout2d 33 | norm_op = nn.InstanceNorm2d 34 | 35 | norm_op_kwargs = {'eps': 1e-5, 'affine': True} 36 | dropout_op_kwargs = {'p': 0, 'inplace': True} 37 | net_nonlin = nn.LeakyReLU 38 | net_nonlin_kwargs = {'inplace': True, 'negative_slope': 2e-1} 39 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 40 | len(self.net_num_pool_op_kernel_sizes), 41 | self.conv_per_stage, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 42 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(0), 43 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True) 44 | if torch.cuda.is_available(): 45 | self.network.cuda() 46 | self.network.inference_apply_nonlin = softmax_helper 47 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_NoNormalization.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.generic_UNet import Generic_UNet 17 | from nnunet.network_architecture.initialization import InitWeights_He 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | from nnunet.network_architecture.custom_modules.helperModules import Identity 20 | from nnunet.utilities.nd_softmax import softmax_helper 21 | from torch import nn 22 | 23 | 24 | class nnUNetTrainerV2_NoNormalization(nnUNetTrainerV2): 25 | def initialize_network(self): 26 | if self.threeD: 27 | conv_op = nn.Conv3d 28 | dropout_op = nn.Dropout3d 29 | norm_op = Identity 30 | 31 | else: 32 | conv_op = nn.Conv2d 33 | dropout_op = nn.Dropout2d 34 | norm_op = Identity 35 | 36 | norm_op_kwargs = {} 37 | dropout_op_kwargs = {'p': 0, 'inplace': True} 38 | net_nonlin = nn.LeakyReLU 39 | net_nonlin_kwargs = {'negative_slope': 1e-2, 'inplace': True} 40 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 41 | len(self.net_num_pool_op_kernel_sizes), 42 | self.conv_per_stage, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 43 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(1e-2), 44 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True) 45 | if torch.cuda.is_available(): 46 | self.network.cuda() 47 | self.network.inference_apply_nonlin = softmax_helper 48 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_NoNormalization_lr1en3.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNet_variants.architectural_variants.nnUNetTrainerV2_NoNormalization import \ 17 | nnUNetTrainerV2_NoNormalization 18 | 19 | 20 | class nnUNetTrainerV2_NoNormalization_lr1en3(nnUNetTrainerV2_NoNormalization): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | self.initial_lr = 1e-3 26 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_ReLU.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.generic_UNet import Generic_UNet 17 | from nnunet.network_architecture.initialization import InitWeights_He 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | from nnunet.utilities.nd_softmax import softmax_helper 20 | from torch import nn 21 | 22 | 23 | class nnUNetTrainerV2_ReLU(nnUNetTrainerV2): 24 | def initialize_network(self): 25 | if self.threeD: 26 | conv_op = nn.Conv3d 27 | dropout_op = nn.Dropout3d 28 | norm_op = nn.InstanceNorm3d 29 | 30 | else: 31 | conv_op = nn.Conv2d 32 | dropout_op = nn.Dropout2d 33 | norm_op = nn.InstanceNorm2d 34 | 35 | norm_op_kwargs = {'eps': 1e-5, 'affine': True} 36 | dropout_op_kwargs = {'p': 0, 'inplace': True} 37 | net_nonlin = nn.ReLU 38 | net_nonlin_kwargs = {'inplace': True} 39 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 40 | len(self.net_num_pool_op_kernel_sizes), 41 | self.conv_per_stage, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 42 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(0), 43 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True) 44 | if torch.cuda.is_available(): 45 | self.network.cuda() 46 | self.network.inference_apply_nonlin = softmax_helper 47 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_ReLU_biasInSegOutput.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.generic_UNet import Generic_UNet 17 | from nnunet.network_architecture.initialization import InitWeights_He 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | from nnunet.utilities.nd_softmax import softmax_helper 20 | from torch import nn 21 | 22 | 23 | class nnUNetTrainerV2_ReLU_biasInSegOutput(nnUNetTrainerV2): 24 | def initialize_network(self): 25 | if self.threeD: 26 | conv_op = nn.Conv3d 27 | dropout_op = nn.Dropout3d 28 | norm_op = nn.InstanceNorm3d 29 | 30 | else: 31 | conv_op = nn.Conv2d 32 | dropout_op = nn.Dropout2d 33 | norm_op = nn.InstanceNorm2d 34 | 35 | norm_op_kwargs = {'eps': 1e-5, 'affine': True} 36 | dropout_op_kwargs = {'p': 0, 'inplace': True} 37 | net_nonlin = nn.ReLU 38 | net_nonlin_kwargs = {'inplace': True} 39 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 40 | len(self.net_num_pool_op_kernel_sizes), 41 | self.conv_per_stage, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 42 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(0), 43 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True, 44 | seg_output_use_bias=True) 45 | self.network.cuda() 46 | self.network.inference_apply_nonlin = softmax_helper 47 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_ReLU_convReLUIN.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.generic_UNet import Generic_UNet, ConvDropoutNonlinNorm 17 | from nnunet.network_architecture.initialization import InitWeights_He 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | from nnunet.utilities.nd_softmax import softmax_helper 20 | from torch import nn 21 | 22 | 23 | class nnUNetTrainerV2_ReLU_convReLUIN(nnUNetTrainerV2): 24 | def initialize_network(self): 25 | if self.threeD: 26 | conv_op = nn.Conv3d 27 | dropout_op = nn.Dropout3d 28 | norm_op = nn.InstanceNorm3d 29 | 30 | else: 31 | conv_op = nn.Conv2d 32 | dropout_op = nn.Dropout2d 33 | norm_op = nn.InstanceNorm2d 34 | 35 | norm_op_kwargs = {'eps': 1e-5, 'affine': True} 36 | dropout_op_kwargs = {'p': 0, 'inplace': True} 37 | net_nonlin = nn.ReLU 38 | net_nonlin_kwargs = {'inplace': True} 39 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 40 | len(self.net_num_pool_op_kernel_sizes), 41 | self.conv_per_stage, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 42 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(0), 43 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True, 44 | basic_block=ConvDropoutNonlinNorm) 45 | if torch.cuda.is_available(): 46 | self.network.cuda() 47 | self.network.inference_apply_nonlin = softmax_helper 48 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_lReLU_biasInSegOutput.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.generic_UNet import Generic_UNet 17 | from nnunet.network_architecture.initialization import InitWeights_He 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | from nnunet.utilities.nd_softmax import softmax_helper 20 | from torch import nn 21 | 22 | 23 | class nnUNetTrainerV2_lReLU_biasInSegOutput(nnUNetTrainerV2): 24 | def initialize_network(self): 25 | if self.threeD: 26 | conv_op = nn.Conv3d 27 | dropout_op = nn.Dropout3d 28 | norm_op = nn.InstanceNorm3d 29 | 30 | else: 31 | conv_op = nn.Conv2d 32 | dropout_op = nn.Dropout2d 33 | norm_op = nn.InstanceNorm2d 34 | 35 | norm_op_kwargs = {'eps': 1e-5, 'affine': True} 36 | dropout_op_kwargs = {'p': 0, 'inplace': True} 37 | net_nonlin = nn.LeakyReLU 38 | net_nonlin_kwargs = {'negative_slope': 1e-2, 'inplace': True} 39 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 40 | len(self.net_num_pool_op_kernel_sizes), 41 | self.conv_per_stage, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 42 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(0), 43 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True, 44 | seg_output_use_bias=True) 45 | if torch.cuda.is_available(): 46 | self.network.cuda() 47 | self.network.inference_apply_nonlin = softmax_helper 48 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/architectural_variants/nnUNetTrainerV2_lReLU_convlReLUIN.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.network_architecture.generic_UNet import Generic_UNet, ConvDropoutNonlinNorm 17 | from nnunet.network_architecture.initialization import InitWeights_He 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | from nnunet.utilities.nd_softmax import softmax_helper 20 | from torch import nn 21 | 22 | 23 | class nnUNetTrainerV2_lReLU_convReLUIN(nnUNetTrainerV2): 24 | def initialize_network(self): 25 | if self.threeD: 26 | conv_op = nn.Conv3d 27 | dropout_op = nn.Dropout3d 28 | norm_op = nn.InstanceNorm3d 29 | 30 | else: 31 | conv_op = nn.Conv2d 32 | dropout_op = nn.Dropout2d 33 | norm_op = nn.InstanceNorm2d 34 | 35 | norm_op_kwargs = {'eps': 1e-5, 'affine': True} 36 | dropout_op_kwargs = {'p': 0, 'inplace': True} 37 | net_nonlin = nn.LeakyReLU 38 | net_nonlin_kwargs = {'inplace': True, 'negative_slope': 1e-2} 39 | self.network = Generic_UNet(self.num_input_channels, self.base_num_features, self.num_classes, 40 | len(self.net_num_pool_op_kernel_sizes), 41 | self.conv_per_stage, 2, conv_op, norm_op, norm_op_kwargs, dropout_op, dropout_op_kwargs, 42 | net_nonlin, net_nonlin_kwargs, True, False, lambda x: x, InitWeights_He(1e-2), 43 | self.net_num_pool_op_kernel_sizes, self.net_conv_kernel_sizes, False, True, True, 44 | basic_block=ConvDropoutNonlinNorm) 45 | self.network.cuda() 46 | self.network.inference_apply_nonlin = softmax_helper 47 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__pycache__/nnUNetTrainerV2CascadeFullRes_DAVariants.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__pycache__/nnUNetTrainerV2CascadeFullRes_DAVariants.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__pycache__/nnUNetTrainerV2CascadeFullRes_lowerLR.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__pycache__/nnUNetTrainerV2CascadeFullRes_lowerLR.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__pycache__/nnUNetTrainerV2CascadeFullRes_shorter.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__pycache__/nnUNetTrainerV2CascadeFullRes_shorter.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__pycache__/nnUNetTrainerV2CascadeFullRes_shorter_lowerLR.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/__pycache__/nnUNetTrainerV2CascadeFullRes_shorter_lowerLR.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/nnUNetTrainerV2CascadeFullRes_lowerLR.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2_CascadeFullRes import nnUNetTrainerV2CascadeFullRes 17 | 18 | 19 | class nnUNetTrainerV2CascadeFullRes_lowerLR(nnUNetTrainerV2CascadeFullRes): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, previous_trainer="nnUNetTrainerV2", fp16=False): 22 | super().__init__(plans_file, fold, output_folder, dataset_directory, 23 | batch_dice, stage, unpack_data, deterministic, 24 | previous_trainer, fp16) 25 | self.initial_lr = 1e-3 26 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/nnUNetTrainerV2CascadeFullRes_shorter.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2_CascadeFullRes import nnUNetTrainerV2CascadeFullRes 17 | 18 | 19 | class nnUNetTrainerV2CascadeFullRes_shorter(nnUNetTrainerV2CascadeFullRes): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, previous_trainer="nnUNetTrainerV2", fp16=False): 22 | super().__init__(plans_file, fold, output_folder, dataset_directory, 23 | batch_dice, stage, unpack_data, deterministic, 24 | previous_trainer, fp16) 25 | self.max_num_epochs = 500 26 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/cascade/nnUNetTrainerV2CascadeFullRes_shorter_lowerLR.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2_CascadeFullRes import nnUNetTrainerV2CascadeFullRes 17 | 18 | 19 | class nnUNetTrainerV2CascadeFullRes_shorter_lowerLR(nnUNetTrainerV2CascadeFullRes): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, previous_trainer="nnUNetTrainerV2", fp16=False): 22 | super().__init__(plans_file, fold, output_folder, dataset_directory, 23 | batch_dice, stage, unpack_data, deterministic, 24 | previous_trainer, fp16) 25 | self.max_num_epochs = 500 26 | self.initial_lr = 1e-3 27 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/copies/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/copies/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/copies/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/copies/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/copies/__pycache__/nnUNetTrainerV2_copies.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/copies/__pycache__/nnUNetTrainerV2_copies.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/nnUNetTrainerV2_DA2.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/nnUNetTrainerV2_DA2.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/nnUNetTrainerV2_independentScalePerAxis.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/nnUNetTrainerV2_independentScalePerAxis.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/nnUNetTrainerV2_insaneDA.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/nnUNetTrainerV2_insaneDA.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/nnUNetTrainerV2_noDA.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/nnUNetTrainerV2_noDA.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/nnUNetTrainerV2_noMirroring.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/__pycache__/nnUNetTrainerV2_noMirroring.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/nnUNetTrainerV2_DA2.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | 18 | 19 | class nnUNetTrainerV2_DA2(nnUNetTrainerV2): 20 | def setup_DA_params(self): 21 | super().setup_DA_params() 22 | 23 | self.data_aug_params["independent_scale_factor_for_each_axis"] = True 24 | 25 | if self.threeD: 26 | self.data_aug_params["rotation_p_per_axis"] = 0.5 27 | else: 28 | self.data_aug_params["rotation_p_per_axis"] = 1 29 | 30 | self.data_aug_params["do_additive_brightness"] = True 31 | 32 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/nnUNetTrainerV2_independentScalePerAxis.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | 18 | 19 | class nnUNetTrainerV2_independentScalePerAxis(nnUNetTrainerV2): 20 | def setup_DA_params(self): 21 | super().setup_DA_params() 22 | self.data_aug_params["independent_scale_factor_for_each_axis"] = True 23 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_ForceBD.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_ForceBD.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_ForceSD.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_ForceSD.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_CE.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_CE.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_CEGDL.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_CEGDL.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_Dice.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_Dice.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_DiceTopK10.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_DiceTopK10.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_Dice_lr1en3.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_Dice_lr1en3.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_Dice_squared.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_Dice_squared.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_MCC.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_MCC.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_TopK10.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_Loss_TopK10.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_focalLoss.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_focalLoss.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_graduallyTransitionFromCEToDice.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/__pycache__/nnUNetTrainerV2_graduallyTransitionFromCEToDice.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/nnUNetTrainerV2_ForceBD.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | 18 | 19 | class nnUNetTrainerV2_ForceBD(nnUNetTrainerV2): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, fp16=False): 22 | batch_dice = True 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/nnUNetTrainerV2_ForceSD.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | 18 | 19 | class nnUNetTrainerV2_ForceSD(nnUNetTrainerV2): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, fp16=False): 22 | batch_dice = False 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/nnUNetTrainerV2_Loss_CE.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.loss_functions.ND_Crossentropy import CrossentropyND 18 | 19 | 20 | class nnUNetTrainerV2_Loss_CE(nnUNetTrainerV2): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | self.loss = CrossentropyND() 26 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/nnUNetTrainerV2_Loss_CEGDL.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.loss_functions.dice_loss import GDL_and_CE_loss 18 | 19 | 20 | class nnUNetTrainerV2_Loss_CEGDL(nnUNetTrainerV2): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | self.loss = GDL_and_CE_loss({'batch_dice': self.batch_dice, 'smooth': 1e-5, 'do_bg': False}, {}) 26 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/nnUNetTrainerV2_Loss_Dice.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.loss_functions.dice_loss import SoftDiceLoss 18 | from nnunet.utilities.nd_softmax import softmax_helper 19 | 20 | 21 | class nnUNetTrainerV2_Loss_Dice(nnUNetTrainerV2): 22 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 23 | unpack_data=True, deterministic=True, fp16=False): 24 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 25 | deterministic, fp16) 26 | self.loss = SoftDiceLoss(**{'apply_nonlin': softmax_helper, 'batch_dice': self.batch_dice, 'smooth': 1e-5, 'do_bg': False}) 27 | 28 | 29 | class nnUNetTrainerV2_Loss_DicewithBG(nnUNetTrainerV2): 30 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 31 | unpack_data=True, deterministic=True, fp16=False): 32 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 33 | deterministic, fp16) 34 | self.loss = SoftDiceLoss(**{'apply_nonlin': softmax_helper, 'batch_dice': self.batch_dice, 'smooth': 1e-5, 'do_bg': True}) 35 | 36 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/nnUNetTrainerV2_Loss_DiceTopK10.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.loss_functions.dice_loss import DC_and_topk_loss 18 | 19 | 20 | class nnUNetTrainerV2_Loss_DiceTopK10(nnUNetTrainerV2): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | self.loss = DC_and_topk_loss({'batch_dice': self.batch_dice, 'smooth': 1e-5, 'do_bg': False}, 26 | {'k': 10}) 27 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/nnUNetTrainerV2_Loss_Dice_lr1en3.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNet_variants.loss_function.nnUNetTrainerV2_Loss_Dice import \ 17 | nnUNetTrainerV2_Loss_Dice, nnUNetTrainerV2_Loss_DicewithBG 18 | 19 | 20 | class nnUNetTrainerV2_Loss_Dice_LR1en3(nnUNetTrainerV2_Loss_Dice): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | self.initial_lr = 1e-3 26 | 27 | 28 | class nnUNetTrainerV2_Loss_DicewithBG_LR1en3(nnUNetTrainerV2_Loss_DicewithBG): 29 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 30 | unpack_data=True, deterministic=True, fp16=False): 31 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 32 | deterministic, fp16) 33 | self.initial_lr = 1e-3 34 | 35 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/nnUNetTrainerV2_Loss_Dice_squared.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.loss_functions.dice_loss import SoftDiceLossSquared 18 | from nnunet.utilities.nd_softmax import softmax_helper 19 | 20 | 21 | class nnUNetTrainerV2_Loss_Dice_squared(nnUNetTrainerV2): 22 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 23 | unpack_data=True, deterministic=True, fp16=False): 24 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 25 | deterministic, fp16) 26 | self.initial_lr = 1e-3 27 | self.loss = SoftDiceLossSquared(**{'apply_nonlin': softmax_helper, 'batch_dice': self.batch_dice, 'smooth': 1e-5, 'do_bg': False}) 28 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/nnUNetTrainerV2_Loss_MCC.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.loss_functions.dice_loss import MCCLoss 18 | from nnunet.utilities.nd_softmax import softmax_helper 19 | 20 | 21 | class nnUNetTrainerV2_Loss_MCC(nnUNetTrainerV2): 22 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 23 | unpack_data=True, deterministic=True, fp16=False): 24 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 25 | deterministic, fp16) 26 | self.initial_lr = 1e-3 27 | self.loss = MCCLoss(apply_nonlin=softmax_helper, batch_mcc=self.batch_dice, do_bg=True, smooth=0.0) 28 | 29 | 30 | class nnUNetTrainerV2_Loss_MCCnoBG(nnUNetTrainerV2): 31 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 32 | unpack_data=True, deterministic=True, fp16=False): 33 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 34 | deterministic, fp16) 35 | self.initial_lr = 1e-3 36 | self.loss = MCCLoss(apply_nonlin=softmax_helper, batch_mcc=self.batch_dice, do_bg=False, smooth=0.0) 37 | 38 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/loss_function/nnUNetTrainerV2_Loss_TopK10.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.loss_functions.TopK_loss import TopKLoss 18 | 19 | 20 | class nnUNetTrainerV2_Loss_TopK10(nnUNetTrainerV2): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | self.loss = TopKLoss(k=10) 26 | 27 | 28 | nnUNetTrainerV2_Loss_TopK10_copy1 = nnUNetTrainerV2_Loss_TopK10 29 | nnUNetTrainerV2_Loss_TopK10_copy2 = nnUNetTrainerV2_Loss_TopK10 30 | nnUNetTrainerV2_Loss_TopK10_copy3 = nnUNetTrainerV2_Loss_TopK10 31 | nnUNetTrainerV2_Loss_TopK10_copy4 = nnUNetTrainerV2_Loss_TopK10 32 | 33 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/miscellaneous/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/miscellaneous/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/miscellaneous/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/miscellaneous/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/miscellaneous/__pycache__/nnUNetTrainerV2_fullEvals.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/miscellaneous/__pycache__/nnUNetTrainerV2_fullEvals.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/nnUNetTrainerCE.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.loss_functions.ND_Crossentropy import CrossentropyND 17 | from nnunet.training.network_training.nnUNetTrainer import nnUNetTrainer 18 | 19 | 20 | class nnUNetTrainerCE(nnUNetTrainer): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super(nnUNetTrainerCE, self).__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, 24 | unpack_data, deterministic, fp16) 25 | self.loss = CrossentropyND() 26 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Adam.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Adam.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Adam_ReduceOnPlateau.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Adam_ReduceOnPlateau.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Adam_lr_3en4.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Adam_lr_3en4.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_O2.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_O2.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Ranger_lr1en2.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Ranger_lr1en2.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Ranger_lr3en3.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Ranger_lr3en3.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Ranger_lr3en4.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_Ranger_lr3en4.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_SGD_ReduceOnPlateau.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_SGD_ReduceOnPlateau.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_SGD_fixedSchedule.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_SGD_fixedSchedule.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_SGD_fixedSchedule2.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_SGD_fixedSchedule2.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_SGD_lrs.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_SGD_lrs.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_cycleAtEnd.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_cycleAtEnd.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_fp16.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_fp16.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_momentum09.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_momentum09.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_momentum095.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_momentum095.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_momentum098.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_momentum098.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_momentum09in2D.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_momentum09in2D.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_reduceMomentumDuringTraining.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_reduceMomentumDuringTraining.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_warmup.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/__pycache__/nnUNetTrainerV2_warmup.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_Adam.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | import torch 17 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 18 | 19 | 20 | class nnUNetTrainerV2_Adam(nnUNetTrainerV2): 21 | 22 | def initialize_optimizer_and_scheduler(self): 23 | self.optimizer = torch.optim.Adam(self.network.parameters(), self.initial_lr, weight_decay=self.weight_decay, amsgrad=True) 24 | self.lr_scheduler = None 25 | 26 | 27 | nnUNetTrainerV2_Adam_copy1 = nnUNetTrainerV2_Adam 28 | nnUNetTrainerV2_Adam_copy2 = nnUNetTrainerV2_Adam 29 | nnUNetTrainerV2_Adam_copy3 = nnUNetTrainerV2_Adam 30 | nnUNetTrainerV2_Adam_copy4 = nnUNetTrainerV2_Adam 31 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_Adam_lr_3en4.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNet_variants.optimizer_and_lr.nnUNetTrainerV2_Adam import nnUNetTrainerV2_Adam 17 | 18 | 19 | class nnUNetTrainerV2_Adam_nnUNetTrainerlr(nnUNetTrainerV2_Adam): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, fp16=False): 22 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 23 | deterministic, fp16) 24 | self.initial_lr = 3e-4 25 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_O2.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | import torch 17 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 18 | try: 19 | from apex import amp 20 | except ImportError: 21 | amp = None 22 | 23 | 24 | class nnUNetTrainerV2_O2(nnUNetTrainerV2): 25 | """ 26 | force O2 in amp 27 | """ 28 | def _maybe_init_amp(self): 29 | if self.fp16 and torch.cuda.is_available(): 30 | if not self.amp_initialized: 31 | if amp is not None: 32 | self.network, self.optimizer = amp.initialize(self.network, self.optimizer, opt_level="O1") 33 | self.amp_initialized = True 34 | else: 35 | raise RuntimeError("WARNING: FP16 training was requested but nvidia apex is not installed. " 36 | "Install it from https://github.com/NVIDIA/apex") 37 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_Ranger_lr1en2.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.optimizer.ranger import Ranger 18 | 19 | 20 | class nnUNetTrainerV2_Ranger_lr1en2(nnUNetTrainerV2): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | self.initial_lr = 1e-2 26 | 27 | def initialize_optimizer_and_scheduler(self): 28 | self.optimizer = Ranger(self.network.parameters(), self.initial_lr, k=6, N_sma_threshhold=5, 29 | weight_decay=self.weight_decay) 30 | self.lr_scheduler = None 31 | 32 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_Ranger_lr3en3.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.optimizer.ranger import Ranger 18 | 19 | 20 | class nnUNetTrainerV2_Ranger_lr3en3(nnUNetTrainerV2): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | self.initial_lr = 3e-3 26 | 27 | def initialize_optimizer_and_scheduler(self): 28 | self.optimizer = Ranger(self.network.parameters(), self.initial_lr, k=6, N_sma_threshhold=5, 29 | weight_decay=self.weight_decay) 30 | self.lr_scheduler = None 31 | 32 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_Ranger_lr3en4.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | from nnunet.training.optimizer.ranger import Ranger 18 | 19 | 20 | class nnUNetTrainerV2_Ranger_lr3en4(nnUNetTrainerV2): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | self.initial_lr = 3e-4 26 | 27 | def initialize_optimizer_and_scheduler(self): 28 | self.optimizer = Ranger(self.network.parameters(), self.initial_lr, k=6, N_sma_threshhold=5, 29 | weight_decay=self.weight_decay) 30 | self.lr_scheduler = None 31 | 32 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_SGD_fixedSchedule.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | 18 | 19 | class nnUNetTrainerV2_SGD_fixedSchedule(nnUNetTrainerV2): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, fp16=False): 22 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 23 | deterministic, fp16) 24 | 25 | def maybe_update_lr(self, epoch=None): 26 | if epoch is None: 27 | ep = self.epoch + 1 28 | else: 29 | ep = epoch 30 | 31 | if 0 <= ep < 500: 32 | new_lr = self.initial_lr 33 | elif 500 <= ep < 675: 34 | new_lr = self.initial_lr * 0.1 35 | elif 675 <= ep < 850: 36 | new_lr = self.initial_lr * 0.01 37 | elif ep >= 850: 38 | new_lr = self.initial_lr * 0.001 39 | else: 40 | raise RuntimeError("Really unexpected things happened, ep=%d" % ep) 41 | 42 | self.optimizer.param_groups[0]['lr'] = new_lr 43 | self.print_to_log_file("lr:", self.optimizer.param_groups[0]['lr']) 44 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_SGD_fixedSchedule2.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.learning_rate.poly_lr import poly_lr 17 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 18 | 19 | 20 | class nnUNetTrainerV2_SGD_fixedSchedule2(nnUNetTrainerV2): 21 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 22 | unpack_data=True, deterministic=True, fp16=False): 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | 26 | def maybe_update_lr(self, epoch=None): 27 | """ 28 | here we go one step, then use polyLR 29 | :param epoch: 30 | :return: 31 | """ 32 | if epoch is None: 33 | ep = self.epoch + 1 34 | else: 35 | ep = epoch 36 | 37 | if 0 <= ep < 500: 38 | new_lr = self.initial_lr 39 | elif 500 <= ep < 675: 40 | new_lr = self.initial_lr * 0.1 41 | elif ep >= 675: 42 | new_lr = poly_lr(ep - 675, self.max_num_epochs - 675, self.initial_lr * 0.1, 0.9) 43 | else: 44 | raise RuntimeError("Really unexpected things happened, ep=%d" % ep) 45 | 46 | self.optimizer.param_groups[0]['lr'] = new_lr 47 | self.print_to_log_file("lr:", self.optimizer.param_groups[0]['lr']) 48 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_SGD_lrs.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | 18 | 19 | class nnUNetTrainerV2_SGD_lr1en1(nnUNetTrainerV2): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, fp16=False): 22 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 23 | deterministic, fp16) 24 | self.initial_lr = 1e-1 25 | 26 | 27 | class nnUNetTrainerV2_SGD_lr1en3(nnUNetTrainerV2): 28 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 29 | unpack_data=True, deterministic=True, fp16=False): 30 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 31 | deterministic, fp16) 32 | self.initial_lr = 1e-3 33 | 34 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_fp16.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | 18 | 19 | class nnUNetTrainerV2_fp16(nnUNetTrainerV2): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, fp16=False): 22 | assert fp16, "This one only accepts fp16=True" 23 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 24 | deterministic, fp16) 25 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_momentum09.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | import torch 17 | 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | 20 | 21 | class nnUNetTrainerV2_momentum09(nnUNetTrainerV2): 22 | def initialize_optimizer_and_scheduler(self): 23 | assert self.network is not None, "self.initialize_network must be called first" 24 | self.optimizer = torch.optim.SGD(self.network.parameters(), self.initial_lr, weight_decay=self.weight_decay, 25 | momentum=0.9, nesterov=True) 26 | self.lr_scheduler = None 27 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_momentum095.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | import torch 17 | 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | 20 | 21 | class nnUNetTrainerV2_momentum095(nnUNetTrainerV2): 22 | def initialize_optimizer_and_scheduler(self): 23 | assert self.network is not None, "self.initialize_network must be called first" 24 | self.optimizer = torch.optim.SGD(self.network.parameters(), self.initial_lr, weight_decay=self.weight_decay, 25 | momentum=0.95, nesterov=True) 26 | self.lr_scheduler = None 27 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_momentum098.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | import torch 17 | 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | 20 | 21 | class nnUNetTrainerV2_momentum098(nnUNetTrainerV2): 22 | def initialize_optimizer_and_scheduler(self): 23 | assert self.network is not None, "self.initialize_network must be called first" 24 | self.optimizer = torch.optim.SGD(self.network.parameters(), self.initial_lr, weight_decay=self.weight_decay, 25 | momentum=0.98, nesterov=True) 26 | self.lr_scheduler = None 27 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_momentum09in2D.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | import torch 17 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 18 | 19 | 20 | class nnUNetTrainerV2_momentum09in2D(nnUNetTrainerV2): 21 | def initialize_optimizer_and_scheduler(self): 22 | if self.threeD: 23 | momentum = 0.99 24 | else: 25 | momentum = 0.9 26 | assert self.network is not None, "self.initialize_network must be called first" 27 | self.optimizer = torch.optim.SGD(self.network.parameters(), self.initial_lr, weight_decay=self.weight_decay, 28 | momentum=momentum, nesterov=True) 29 | self.lr_scheduler = None 30 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_reduceMomentumDuringTraining.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | import torch 17 | 18 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 19 | 20 | 21 | class nnUNetTrainerV2_reduceMomentumDuringTraining(nnUNetTrainerV2): 22 | """ 23 | This implementation will not work with LR scheduler!!!!!!!!!! 24 | 25 | After epoch 800, linearly decrease momentum from 0.99 to 0.9 26 | """ 27 | def initialize_optimizer_and_scheduler(self): 28 | current_momentum = 0.99 29 | min_momentum = 0.9 30 | 31 | if self.epoch > 800: 32 | current_momentum = current_momentum - (current_momentum - min_momentum) / 200 * (self.epoch - 800) 33 | 34 | self.print_to_log_file("current momentum", current_momentum) 35 | assert self.network is not None, "self.initialize_network must be called first" 36 | if self.optimizer is None: 37 | self.optimizer = torch.optim.SGD(self.network.parameters(), self.initial_lr, weight_decay=self.weight_decay, 38 | momentum=0.99, nesterov=True) 39 | else: 40 | # can't reinstantiate because that would break NVIDIA AMP 41 | self.optimizer.param_groups[0]["momentum"] = current_momentum 42 | self.lr_scheduler = None 43 | 44 | def on_epoch_end(self): 45 | self.initialize_optimizer_and_scheduler() 46 | return super().on_epoch_end() 47 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/optimizer_and_lr/nnUNetTrainerV2_warmup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | 18 | 19 | class nnUNetTrainerV2_warmup(nnUNetTrainerV2): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, fp16=False): 22 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 23 | deterministic, fp16) 24 | self.max_num_epochs = 1050 25 | 26 | def maybe_update_lr(self, epoch=None): 27 | if self.epoch < 50: 28 | # epoch 49 is max 29 | # we increase lr linearly from 0 to initial_lr 30 | lr = (self.epoch + 1) / 50 * self.initial_lr 31 | self.optimizer.param_groups[0]['lr'] = lr 32 | self.print_to_log_file("epoch:", self.epoch, "lr:", lr) 33 | else: 34 | if epoch is not None: 35 | ep = epoch - 49 36 | else: 37 | ep = self.epoch - 49 38 | assert ep > 0, "epoch must be >0" 39 | return super().maybe_update_lr(ep) 40 | -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/profiling/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/profiling/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/profiling/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/profiling/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/profiling/__pycache__/nnUNetTrainerV2_2epochs.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/profiling/__pycache__/nnUNetTrainerV2_2epochs.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/profiling/nnUNetTrainerV2_2epochs.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from typing import Tuple 15 | import numpy as np 16 | from nnunet.training.network_training.nnUNetTrainerV2 import nnUNetTrainerV2 17 | 18 | 19 | class nnUNetTrainerV2_2epochs(nnUNetTrainerV2): 20 | def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None, 21 | unpack_data=True, deterministic=True, fp16=False): 22 | super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage, unpack_data, 23 | deterministic, fp16) 24 | self.max_num_epochs = 2 25 | 26 | def validate(self, do_mirroring: bool = True, use_sliding_window: bool = True, step_size: float = 0.5, 27 | save_softmax: bool = True, use_gaussian: bool = True, overwrite: bool = True, 28 | validation_folder_name: str = 'validation_raw', debug: bool = False, all_in_gpu: bool = False, 29 | force_separate_z: bool = None, interpolation_order: int = 3, interpolation_order_z=0): 30 | pass 31 | 32 | def predict_preprocessed_data_return_seg_and_softmax(self, data: np.ndarray, do_mirroring: bool = True, 33 | mirror_axes: Tuple[int] = None, use_sliding_window: bool = True, 34 | step_size: float = 0.5, use_gaussian: bool = True, 35 | pad_border_mode: str = 'constant', pad_kwargs: dict = None, 36 | all_in_gpu: bool = True, 37 | verbose: bool = True) -> Tuple[np.ndarray, np.ndarray]: 38 | pass -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/resampling/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/resampling/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/resampling/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/resampling/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/network_training/nnUNet_variants/resampling/__pycache__/nnUNetTrainerV2_resample33.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/network_training/nnUNet_variants/resampling/__pycache__/nnUNetTrainerV2_resample33.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/optimizer/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/optimizer/__init__.py -------------------------------------------------------------------------------- /nnUNet/nnunet/training/optimizer/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/optimizer/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/training/optimizer/__pycache__/ranger.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/training/optimizer/__pycache__/ranger.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from . import * -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/utilities/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/__pycache__/distributed.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/utilities/__pycache__/distributed.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/__pycache__/file_endings.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/utilities/__pycache__/file_endings.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/__pycache__/nd_softmax.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/utilities/__pycache__/nd_softmax.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/__pycache__/one_hot_encoding.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/utilities/__pycache__/one_hot_encoding.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/__pycache__/sitk_stuff.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/utilities/__pycache__/sitk_stuff.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/__pycache__/task_name_id_conversion.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/utilities/__pycache__/task_name_id_conversion.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/__pycache__/tensor_utilities.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/utilities/__pycache__/tensor_utilities.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/__pycache__/to_torch.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/nnUNet/nnunet/utilities/__pycache__/to_torch.cpython-37.pyc -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/file_endings.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from batchgenerators.utilities.file_and_folder_operations import * 17 | 18 | 19 | def remove_trailing_slash(filename: str): 20 | while filename.endswith('/'): 21 | filename = filename[:-1] 22 | return filename 23 | 24 | 25 | def maybe_add_0000_to_all_niigz(folder): 26 | nii_gz = subfiles(folder, suffix='.nii.gz') 27 | for n in nii_gz: 28 | n = remove_trailing_slash(n) 29 | if not n.endswith('_0000.nii.gz'): 30 | os.rename(n, n[:-7] + '_0000.nii.gz') 31 | -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/folder_names.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from batchgenerators.utilities.file_and_folder_operations import * 17 | from nnunet.paths import network_training_output_dir 18 | 19 | 20 | def get_output_folder_name(model: str, task: str = None, trainer: str = None, plans: str = None, fold: int = None, 21 | overwrite_training_output_dir: str = None): 22 | """ 23 | Retrieves the correct output directory for the nnU-Net model described by the input parameters 24 | 25 | :param model: 26 | :param task: 27 | :param trainer: 28 | :param plans: 29 | :param fold: 30 | :param overwrite_training_output_dir: 31 | :return: 32 | """ 33 | assert model in ["2d", "3d_cascade_fullres", '3d_fullres', '3d_lowres'] 34 | 35 | if overwrite_training_output_dir is not None: 36 | tr_dir = overwrite_training_output_dir 37 | else: 38 | tr_dir = network_training_output_dir 39 | 40 | current = join(tr_dir, model) 41 | if task is not None: 42 | current = join(current, task) 43 | if trainer is not None and plans is not None: 44 | current = join(current, trainer + "__" + plans) 45 | if fold is not None: 46 | current = join(current, "fold_%d" % fold) 47 | return current 48 | -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/nd_softmax.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | 17 | 18 | def softmax_helper(x): 19 | rpt = [1 for _ in range(len(x.size()))] 20 | rpt[1] = x.size(1) 21 | x_max = x.max(1, keepdim=True)[0].repeat(*rpt) 22 | e_x = torch.exp(x - x_max) 23 | return e_x / e_x.sum(1, keepdim=True).repeat(*rpt) 24 | -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/one_hot_encoding.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import numpy as np 16 | 17 | 18 | def to_one_hot(seg, all_seg_labels=None): 19 | if all_seg_labels is None: 20 | all_seg_labels = np.unique(seg) 21 | result = np.zeros((len(all_seg_labels), *seg.shape), dtype=seg.dtype) 22 | for i, l in enumerate(all_seg_labels): 23 | result[i][seg == l] = 1 24 | return result 25 | -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/recursive_delete_npz.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from batchgenerators.utilities.file_and_folder_operations import * 17 | import argparse 18 | import os 19 | 20 | 21 | def recursive_delete_npz(current_directory: str): 22 | npz_files = subfiles(current_directory, join=True, suffix=".npz") 23 | npz_files = [i for i in npz_files if not i.endswith("segFromPrevStage.npz")] # to be extra safe 24 | _ = [os.remove(i) for i in npz_files] 25 | for d in subdirs(current_directory, join=False): 26 | if d != "pred_next_stage": 27 | recursive_delete_npz(join(current_directory, d)) 28 | 29 | 30 | if __name__ == "__main__": 31 | parser = argparse.ArgumentParser(usage="USE THIS RESPONSIBLY! DANGEROUS! I (Fabian) use this to remove npz files " 32 | "after I ran figure_out_what_to_submit") 33 | parser.add_argument("-f", help="folder", required=True) 34 | 35 | args = parser.parse_args() 36 | 37 | recursive_delete_npz(args.f) 38 | -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/recursive_rename_taskXX_to_taskXXX.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from batchgenerators.utilities.file_and_folder_operations import * 17 | import os 18 | 19 | 20 | def recursive_rename(folder): 21 | s = subdirs(folder, join=False) 22 | for ss in s: 23 | if ss.startswith("Task") and ss.find("_") == 6: 24 | task_id = int(ss[4:6]) 25 | name = ss[7:] 26 | os.rename(join(folder, ss), join(folder, "Task%03.0d_" % task_id + name)) 27 | s = subdirs(folder, join=True) 28 | for ss in s: 29 | recursive_rename(ss) 30 | 31 | if __name__ == "__main__": 32 | recursive_rename("/media/fabian/Results/nnUNet") 33 | recursive_rename("/media/fabian/nnunet") 34 | recursive_rename("/media/fabian/My Book/MedicalDecathlon") 35 | recursive_rename("/home/fabian/drives/datasets/nnUNet_raw") 36 | recursive_rename("/home/fabian/drives/datasets/nnUNet_preprocessed") 37 | recursive_rename("/home/fabian/drives/datasets/nnUNet_testSets") 38 | recursive_rename("/home/fabian/drives/datasets/results/nnUNet") 39 | recursive_rename("/home/fabian/drives/e230-dgx2-1-data_fabian/Decathlon_raw") 40 | recursive_rename("/home/fabian/drives/e230-dgx2-1-data_fabian/nnUNet_preprocessed") 41 | 42 | -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/sitk_stuff.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | import SimpleITK as sitk 17 | 18 | 19 | def copy_geometry(image: sitk.Image, ref: sitk.Image): 20 | image.SetOrigin(ref.GetOrigin()) 21 | image.SetDirection(ref.GetDirection()) 22 | image.SetSpacing(ref.GetSpacing()) 23 | return image 24 | -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/task_name_id_conversion.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from nnunet.paths import nnUNet_raw_data, preprocessing_output_dir, nnUNet_cropped_data 17 | from batchgenerators.utilities.file_and_folder_operations import * 18 | import numpy as np 19 | 20 | 21 | def convert_id_to_task_name(task_id: int): 22 | startswith = "Task%03.0d" % task_id 23 | if preprocessing_output_dir is not None: 24 | candidates_preprocessed = subdirs(preprocessing_output_dir, prefix=startswith, join=False) 25 | else: 26 | candidates_preprocessed = [] 27 | 28 | if nnUNet_raw_data is not None: 29 | candidates_raw = subdirs(nnUNet_raw_data, prefix=startswith, join=False) 30 | else: 31 | candidates_raw = [] 32 | 33 | if nnUNet_cropped_data is not None: 34 | candidates_cropped = subdirs(nnUNet_cropped_data, prefix=startswith, join=False) 35 | else: 36 | candidates_cropped = [] 37 | 38 | all_candidates = candidates_cropped + candidates_preprocessed + candidates_raw 39 | unique_candidates = np.unique(all_candidates) 40 | if len(unique_candidates) > 1: 41 | raise RuntimeError("More than one task name found for task id %d. Please correct that. (I looked in the " 42 | "following folders:\n%s\n%s\n%s" % (task_id, nnUNet_raw_data, preprocessing_output_dir, 43 | nnUNet_cropped_data)) 44 | if len(unique_candidates) == 0: 45 | raise RuntimeError("Could not find a task with the ID %d. Make sure the requested task ID exists and that " 46 | "nnU-Net knows where raw and preprocessed data are located (see Documentation - " 47 | "Installation)." % task_id) 48 | return unique_candidates[0] 49 | 50 | 51 | def convert_task_name_to_id(task_name: str): 52 | assert task_name.startswith("Task") 53 | task_id = int(task_name[4:7]) 54 | return task_id 55 | -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/tensor_utilities.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import numpy as np 16 | import torch 17 | from torch import nn 18 | 19 | 20 | def sum_tensor(inp, axes, keepdim=False): 21 | axes = np.unique(axes).astype(int) 22 | if keepdim: 23 | for ax in axes: 24 | inp = inp.sum(int(ax), keepdim=True) 25 | else: 26 | for ax in sorted(axes, reverse=True): 27 | inp = inp.sum(int(ax)) 28 | return inp 29 | 30 | 31 | def mean_tensor(inp, axes, keepdim=False): 32 | axes = np.unique(axes).astype(int) 33 | if keepdim: 34 | for ax in axes: 35 | inp = inp.mean(int(ax), keepdim=True) 36 | else: 37 | for ax in sorted(axes, reverse=True): 38 | inp = inp.mean(int(ax)) 39 | return inp 40 | 41 | 42 | def flip(x, dim): 43 | """ 44 | flips the tensor at dimension dim (mirroring!) 45 | :param x: 46 | :param dim: 47 | :return: 48 | """ 49 | indices = [slice(None)] * x.dim() 50 | indices[dim] = torch.arange(x.size(dim) - 1, -1, -1, 51 | dtype=torch.long, device=x.device) 52 | return x[tuple(indices)] 53 | 54 | 55 | -------------------------------------------------------------------------------- /nnUNet/nnunet/utilities/to_torch.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | 17 | 18 | def maybe_to_torch(d): 19 | if isinstance(d, list): 20 | d = [maybe_to_torch(i) if not isinstance(i, torch.Tensor) else i for i in d] 21 | elif not isinstance(d, torch.Tensor): 22 | d = torch.from_numpy(d).float() 23 | return d 24 | 25 | 26 | def to_cuda(data, non_blocking=True, gpu_id=0): 27 | if isinstance(data, list): 28 | data = [i.cuda(gpu_id, non_blocking=non_blocking) for i in data] 29 | else: 30 | data = data.cuda(gpu_id, non_blocking=True) 31 | return data 32 | -------------------------------------------------------------------------------- /nnUNet/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = readme.md -------------------------------------------------------------------------------- /output/aneurysms.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/output/aneurysms.nii.gz -------------------------------------------------------------------------------- /seg_initial/aneurysms.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JunMa11/ADAM2020/c1670a1883aa6e72f5eb296595bc015f63375705/seg_initial/aneurysms.nii.gz --------------------------------------------------------------------------------