Skip to content

Commit c5d1b2d

Browse files
committed
Drop vendored nnunetv2; depend on upstream pip package (v1.3.0)
BREAKING CHANGE: distillation/nnunetv2/ is removed and replaced with a pip dependency on nnunetv2>=2.5,<3.0. Users must reinstall to pick up the new layout. What changed: - Removed entire distillation/nnunetv2/ vendored tree (~190 files, 1.7 MB). The only file we had authored was nnUNetDistillationTrainer.py; the rest was a stale snapshot of upstream nnUNet that the repo had to manually keep in sync. - Moved the trainer to distillation/nnunet_distillation_trainer.py at the top of the package so it sits next to the entry-point scripts. - Updated the four entry-point scripts to import the trainer from its new location and dropped the sys.path.insert hack that forced the vendored copy to win over pip. - setup.py: pin nnunetv2>=2.5,<3.0, list nnunet_distillation_trainer in py_modules, bump version 1.2.1 -> 1.3.0. Compatibility fix surfaced by the refactor: - nnunetv2 2.7 renamed nnUNetLogger to LocalLogger. Updated the trainer's import and instantiation accordingly. (The vendored copy hid this drift.) Verified locally: - python -m py_compile passes on all touched files. - After `pip install -e .` in distillation/, the four console entry points (nnUNetv2_distillation_train, nnUNetv2_resenc_distillation_train, nnUNetv2_distillation_export_onnx, nnUNetv2_resenc_distillation_export_onnx) all run --help successfully against pip-installed nnunetv2 2.7.0. - nnunet_distillation_trainer exposes nnUNetDistillationTrainer, nnUNetDistillationTrainerDA5, LiteNNUNetStudent, LiteResEncStudent. Not yet verified (requires GPU + dataset): - An end-to-end training step. The autocast/Logger changes need a real training run before this is shipped.
1 parent 3b5aa8e commit c5d1b2d

203 files changed

Lines changed: 17 additions & 18465 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

distillation/fast_nnunet_distillation_export_onnx.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@
2525
import numpy as np
2626
from batchgenerators.utilities.file_and_folder_operations import join, isfile
2727

28-
# Ensure using nnunetv2 from current directory
29-
nnunet_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)))
30-
sys.path.insert(0, nnunet_dir)
31-
32-
# Import paths and related functionalities from nnunetv2
3328
from nnunetv2.paths import nnUNet_results, nnUNet_raw, nnUNet_preprocessed
3429
from nnunetv2.utilities.label_handling.label_handling import determine_num_input_channels
35-
from nnunetv2.training.nnUNetTrainer.variants.nnUNetDistillationTrainer import nnUNetDistillationTrainer, nnUNetDistillationTrainerDA5, LiteNNUNetStudent
30+
31+
from nnunet_distillation_trainer import nnUNetDistillationTrainer, nnUNetDistillationTrainerDA5, LiteNNUNetStudent
3632

3733
def get_dataset_name_from_id(dataset_id):
3834
"""Get the complete dataset name from dataset ID"""

distillation/fast_nnunet_distillation_train.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,11 @@
2828
import json
2929
from batchgenerators.utilities.file_and_folder_operations import join
3030

31-
# Ensure using nnunetv2 from current directory
32-
nnunet_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)))
33-
sys.path.insert(0, nnunet_dir)
34-
35-
# Import paths from nnunetv2
3631
from nnunetv2.paths import nnUNet_results, nnUNet_raw, nnUNet_preprocessed
37-
38-
# Import nnUNetDistillationTrainer directly
39-
from nnunetv2.training.nnUNetTrainer.variants.nnUNetDistillationTrainer import nnUNetDistillationTrainer, nnUNetDistillationTrainerDA5
4032
from nnunetv2.utilities.label_handling.label_handling import determine_num_input_channels
4133

34+
from nnunet_distillation_trainer import nnUNetDistillationTrainer, nnUNetDistillationTrainerDA5
35+
4236
def get_dataset_name_from_id(dataset_id):
4337
"""Get the complete dataset name from dataset ID"""
4438
# Try to convert dataset_id to integer

distillation/fast_nnunet_resenc_distillation_export_onnx.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,12 @@
3636
from onnxruntime import InferenceSession
3737
from torch.onnx import export as torch_onnx_export
3838

39-
# Ensure using nnunetv2 from current directory
40-
nnunet_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)))
41-
sys.path.insert(0, nnunet_dir)
42-
43-
# Import paths from nnunetv2
4439
from nnunetv2.paths import nnUNet_results, nnUNet_raw, nnUNet_preprocessed
45-
46-
# Import nnUNetDistillationTrainer directly
47-
from nnunetv2.training.nnUNetTrainer.variants.nnUNetDistillationTrainer import nnUNetDistillationTrainer, nnUNetDistillationTrainerDA5, LiteNNUNetStudent, LiteResEncStudent
4840
from nnunetv2.utilities.label_handling.label_handling import determine_num_input_channels
4941
from nnunetv2.inference.predict_from_raw_data import nnUNetPredictor
5042

43+
from nnunet_distillation_trainer import nnUNetDistillationTrainer, nnUNetDistillationTrainerDA5, LiteNNUNetStudent, LiteResEncStudent
44+
5145
def get_dataset_name_from_id(dataset_id):
5246
"""Get the complete dataset name from dataset ID"""
5347
# Try to convert dataset_id to integer

distillation/fast_nnunet_resenc_distillation_train.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,11 @@
2828
import json
2929
from batchgenerators.utilities.file_and_folder_operations import join
3030

31-
# Ensure using nnunetv2 from current directory
32-
nnunet_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)))
33-
sys.path.insert(0, nnunet_dir)
34-
35-
# Import paths from nnunetv2
3631
from nnunetv2.paths import nnUNet_results, nnUNet_raw, nnUNet_preprocessed
37-
38-
# Import nnUNetDistillationTrainer directly
39-
from nnunetv2.training.nnUNetTrainer.variants.nnUNetDistillationTrainer import nnUNetDistillationTrainer, nnUNetDistillationTrainerDA5
4032
from nnunetv2.utilities.label_handling.label_handling import determine_num_input_channels
4133

34+
from nnunet_distillation_trainer import nnUNetDistillationTrainer, nnUNetDistillationTrainerDA5
35+
4236
def get_dataset_name_from_id(dataset_id):
4337
"""Get the complete dataset name from dataset ID"""
4438
# Try to convert dataset_id to integer

distillation/nnunetv2/training/nnUNetTrainer/variants/nnUNetDistillationTrainer.py renamed to distillation/nnunet_distillation_trainer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _default_norm_op_for(conv_op):
6767
from nnunetv2.utilities.helpers import empty_cache
6868
from nnunetv2.paths import nnUNet_preprocessed, nnUNet_results
6969
from nnunetv2.utilities.plans_handling.plans_handler import PlansManager
70-
from nnunetv2.training.logging.nnunet_logger import nnUNetLogger
70+
from nnunetv2.training.logging.nnunet_logger import LocalLogger
7171
from datetime import datetime
7272
from time import sleep
7373
import sys
@@ -444,7 +444,7 @@ def patched_init(self, plans, configuration, fold, dataset_json, device):
444444
self.log_file = join(self.output_folder, "training_log_%d_%d_%d_%02.0d_%02.0d_%02.0d.txt" %
445445
(timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute,
446446
timestamp.second))
447-
self.logger = nnUNetLogger()
447+
self.logger = LocalLogger()
448448

449449
self.print_to_log_file("\n#######################################################################\n"
450450
"Please cite the following paper when using nnU-Net:\n"

distillation/nnunetv2/__init__.py

Whitespace-only changes.

distillation/nnunetv2/batch_running/__init__.py

Whitespace-only changes.

distillation/nnunetv2/batch_running/benchmarking/__init__.py

Whitespace-only changes.

distillation/nnunetv2/batch_running/benchmarking/generate_benchmarking_commands.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

distillation/nnunetv2/batch_running/benchmarking/summarize_benchmark_results.py

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)