How mic-dkfz/nndetection works
Main Components
• Data and Configuration Management:
• Configuration files in nndet/conf (with YAML files and prep/train configurations).
• Use of Hydra for dynamic configuration.
• Environment settings (e.g., det_data, det_models, OMP_NUM_THREADS).
• Core Libraries and Modules:
○ Architecture: modules for encoders, decoders, heads, blocks, layers, initialization.
○ Preprocessing and Planning: “nndet/preprocessing” and “nndet/planning” (with experiment and properties registries).
○ Losses: Separate module that implements segmentation, regression and classification losses.
○ PyTorch Lightning Module: “nndet/ptmodule” for training pipelines.
○ Inference modules: This includes assembling outputs via “nndet/inference”, predictor and ensembler components.
• External Registries and Plug-In Points:
• Registries (augmentation, dataloader, planner, module registries) which support modular extension.
• How these registries allow switching between underlying algorithms by reading configuration files.
• Data Input and I/O:
• Components in “nndet/io” covering augmentation, datamodule (data loading), transforms, and patching.
• Expected input data formats (nifti images, labels in JSON) and how data flows from raw to preprocessed stages.
• Scripts and Execution Flow:
• On the periphery, include execution scripts found in the “scripts” folder:
○ Data preparation (nndet_prep, preprocess.py)
○ Unpacking (nndet_unpack)
○ Training (nndet_train and training/optimizer)
○ Consolidation and parameter sweep (nndet_consolidate, nndet_sweep)
○ Inference (nndet_predict)
○ Evaluation (nndet_eval)
• That these are the command line interfaces that trigger pipelines within the core modules.
• Docker and Environment:
• Dockerfile and container setup as an “Infrastructure / Deployment” block. Show environment variables (det_data, det_models) and mounting strategies.
• Mention that the project supports both Docker and local conda installations with tailored environment setups.
Establish Relationships and Data Flow
• From preprocessing, indicate that processed data feeds into both planning and training pipelines.
• That the training module interacts with the core nnDetection module (using PyTorch Lightning wrappers) to produce trained models.
• Detail that trained models are then consolidated (via nndet_consolidate) and further utilized by inference modules for prediction/output.
• To show the dependency from configuration files (Hydra-driven) into nearly every component.
Architectural Patterns and Principles
• Modularity: Emphasize how the architecture leverages a well-organized package structure (separating encoders, decoders, heads, etc.) and registries to allow plug-and-play functionality.
• Data-Driven & Self-configuring: Reflect the automated configuration planning stage that analyzes data properties (refer to planning and preprocessing folders) and dynamically adapts network architectures.
• Pipeline Flow: The project uses sequential stages (prep → train → inference → evaluation) that are each represented as distinct blocks.
Technologies and Frameworks
• Use of PyTorch and its Lightning interface for training.
• CUDA-specific components in “nndet/csrc” (with both CPU and CUDA implementations of operations such as NMS).
• Hydra for configuration and possibly mention integration with external tools such as MLflow.