From 52cab354338ec32548b7b22600c94a6bf4cad1c2 Mon Sep 17 00:00:00 2001 From: Fabian Isensee Date: Tue, 6 Feb 2024 10:28:57 +0100 Subject: [PATCH] align imports with current main of dynamic network architectures --- .../default_experiment_planner.py | 3 ++- .../experiment_planners/resencUNet_planner.py | 2 +- nnunetv2/inference/data_iterators.py | 2 ++ nnunetv2/inference/predict_from_raw_data.py | 14 ++++++++------ .../network_architecture/nnUNetTrainerBN.py | 3 ++- nnunetv2/utilities/get_network_from_plans.py | 3 ++- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/nnunetv2/experiment_planning/experiment_planners/default_experiment_planner.py b/nnunetv2/experiment_planning/experiment_planners/default_experiment_planner.py index b74f43304..173b4a796 100644 --- a/nnunetv2/experiment_planning/experiment_planners/default_experiment_planner.py +++ b/nnunetv2/experiment_planning/experiment_planners/default_experiment_planner.py @@ -5,7 +5,8 @@ import numpy as np from batchgenerators.utilities.file_and_folder_operations import load_json, join, save_json, isfile, maybe_mkdir_p -from dynamic_network_architectures.architectures.unet import PlainConvUNet, ResidualEncoderUNet +from dynamic_network_architectures.architectures.residual_unet import ResidualEncoderUNet +from dynamic_network_architectures.architectures.unet import PlainConvUNet from dynamic_network_architectures.building_blocks.helper import convert_dim_to_conv_op, get_matching_instancenorm from nnunetv2.configuration import ANISO_THRESHOLD diff --git a/nnunetv2/experiment_planning/experiment_planners/resencUNet_planner.py b/nnunetv2/experiment_planning/experiment_planners/resencUNet_planner.py index 52ca938ee..38e2e0a6c 100644 --- a/nnunetv2/experiment_planning/experiment_planners/resencUNet_planner.py +++ b/nnunetv2/experiment_planning/experiment_planners/resencUNet_planner.py @@ -3,7 +3,7 @@ from torch import nn from nnunetv2.experiment_planning.experiment_planners.default_experiment_planner import ExperimentPlanner -from dynamic_network_architectures.architectures.unet import ResidualEncoderUNet +from dynamic_network_architectures.architectures.residual_unet import ResidualEncoderUNet class ResEncUNetPlanner(ExperimentPlanner): diff --git a/nnunetv2/inference/data_iterators.py b/nnunetv2/inference/data_iterators.py index 9dfee4e26..1777fb934 100644 --- a/nnunetv2/inference/data_iterators.py +++ b/nnunetv2/inference/data_iterators.py @@ -53,6 +53,7 @@ def preprocess_fromfiles_save_to_queue(list_of_lists: List[List[str]], pass done_event.set() except Exception as e: + # print(Exception, e) abort_event.set() raise e @@ -99,6 +100,7 @@ def preprocessing_iterator_fromfiles(list_of_lists: List[List[str]], worker_ctr = 0 while (not done_events[worker_ctr].is_set()) or (not target_queues[worker_ctr].empty()): + # import IPython;IPython.embed() if not target_queues[worker_ctr].empty(): item = target_queues[worker_ctr].get() worker_ctr = (worker_ctr + 1) % num_processes diff --git a/nnunetv2/inference/predict_from_raw_data.py b/nnunetv2/inference/predict_from_raw_data.py index 2c2e1f03e..14056d139 100644 --- a/nnunetv2/inference/predict_from_raw_data.py +++ b/nnunetv2/inference/predict_from_raw_data.py @@ -368,8 +368,8 @@ def predict_from_data_iterator(self, if ofile is not None: # this needs to go into background processes - # export_prediction_from_logits(prediction, properties, configuration_manager, plans_manager, - # dataset_json, ofile, save_probabilities) + # export_prediction_from_logits(prediction, properties, self.configuration_manager, self.plans_manager, + # self.dataset_json, ofile, save_probabilities) print('sending off prediction to background worker for resampling and export') r.append( export_pool.starmap_async( @@ -379,10 +379,12 @@ def predict_from_data_iterator(self, ) ) else: - # convert_predicted_logits_to_segmentation_with_correct_shape(prediction, plans_manager, - # configuration_manager, label_manager, - # properties, - # save_probabilities) + # convert_predicted_logits_to_segmentation_with_correct_shape( + # prediction, self.plans_manager, + # self.configuration_manager, self.label_manager, + # properties, + # save_probabilities) + print('sending off prediction to background worker for resampling') r.append( export_pool.starmap_async( diff --git a/nnunetv2/training/nnUNetTrainer/variants/network_architecture/nnUNetTrainerBN.py b/nnunetv2/training/nnUNetTrainer/variants/network_architecture/nnUNetTrainerBN.py index 5f6190c1b..a5588c3fb 100644 --- a/nnunetv2/training/nnUNetTrainer/variants/network_architecture/nnUNetTrainerBN.py +++ b/nnunetv2/training/nnUNetTrainer/variants/network_architecture/nnUNetTrainerBN.py @@ -1,4 +1,5 @@ -from dynamic_network_architectures.architectures.unet import ResidualEncoderUNet, PlainConvUNet +from dynamic_network_architectures.architectures.residual_unet import ResidualEncoderUNet +from dynamic_network_architectures.architectures.unet import PlainConvUNet from dynamic_network_architectures.building_blocks.helper import convert_dim_to_conv_op, get_matching_batchnorm from dynamic_network_architectures.initialization.weight_init import init_last_bn_before_add_to_0, InitWeights_He from nnunetv2.training.nnUNetTrainer.nnUNetTrainer import nnUNetTrainer diff --git a/nnunetv2/utilities/get_network_from_plans.py b/nnunetv2/utilities/get_network_from_plans.py index 1dd1dd2ec..0da14b7b9 100644 --- a/nnunetv2/utilities/get_network_from_plans.py +++ b/nnunetv2/utilities/get_network_from_plans.py @@ -1,4 +1,5 @@ -from dynamic_network_architectures.architectures.unet import PlainConvUNet, ResidualEncoderUNet +from dynamic_network_architectures.architectures.residual_unet import ResidualEncoderUNet +from dynamic_network_architectures.architectures.unet import PlainConvUNet from dynamic_network_architectures.building_blocks.helper import get_matching_instancenorm, convert_dim_to_conv_op from dynamic_network_architectures.initialization.weight_init import init_last_bn_before_add_to_0 from nnunetv2.utilities.network_initialization import InitWeights_He