|
| 1 | +# Copyright (c) MONAI Consortium |
| 2 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +# you may not use this file except in compliance with the License. |
| 4 | +# You may obtain a copy of the License at |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# Unless required by applicable law or agreed to in writing, software |
| 7 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 8 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 9 | +# See the License for the specific language governing permissions and |
| 10 | +# limitations under the License. |
| 11 | + |
| 12 | +""" |
| 13 | +Examples: |
| 14 | + - User can use the one-liner to start the nnU-Net workflow |
| 15 | +
|
| 16 | + .. code-block:: bash |
| 17 | +
|
| 18 | + python -m monai.apps.nnunet nnUNetV2Runner run --input "./input.yaml" |
| 19 | +
|
| 20 | + - convert dataset |
| 21 | +
|
| 22 | + .. code-block:: bash |
| 23 | +
|
| 24 | + python -m monai.apps.nnunet nnUNetRunner convert_dataset --input "./input_new.yaml" |
| 25 | +
|
| 26 | + - convert msd datasets |
| 27 | +
|
| 28 | + .. code-block:: bash |
| 29 | +
|
| 30 | + python -m monai.apps.nnunet nnUNetRunner convert_msd_dataset \\ |
| 31 | + --input "./input.yaml" --data_dir "Task05_Prostate" |
| 32 | +
|
| 33 | + - experiment planning and data pre-processing |
| 34 | +
|
| 35 | + .. code-block:: bash |
| 36 | +
|
| 37 | + python -m monai.apps.nnunet nnUNetRunner plan_and_process --input "./input.yaml" |
| 38 | +
|
| 39 | + - single-gpu training for all 20 models |
| 40 | +
|
| 41 | + .. code-block:: bash |
| 42 | +
|
| 43 | + python -m monai.apps.nnunet nnUNetV2Runner train --input "./input.yaml" |
| 44 | +
|
| 45 | + - single-gpu training for a single model |
| 46 | +
|
| 47 | + .. code-block:: bash |
| 48 | +
|
| 49 | + python -m monai.apps.nnunet nnUNetV2Runner train_single_model --input "./input.yaml" \\ |
| 50 | + --config "3d_fullres" \\ |
| 51 | + --fold 0 \\ |
| 52 | + --trainer_class_name "nnUNetTrainer_5epochs" \\ |
| 53 | + --export_validation_probabilities true |
| 54 | +
|
| 55 | + - multi-gpu training for all 20 models |
| 56 | +
|
| 57 | + .. code-block:: bash |
| 58 | +
|
| 59 | + export CUDA_VISIBLE_DEVICES=0,1 # optional |
| 60 | + python -m monai.apps.nnunet nnUNetV2Runner train --input "./input.yaml" --num_gpus 2 |
| 61 | +
|
| 62 | + - multi-gpu training for a single model |
| 63 | +
|
| 64 | + .. code-block:: bash |
| 65 | +
|
| 66 | + export CUDA_VISIBLE_DEVICES=0,1 # optional |
| 67 | + python -m monai.apps.nnunet nnUNetV2Runner train_single_model --input "./input.yaml" \\ |
| 68 | + --config "3d_fullres" \\ |
| 69 | + --fold 0 \\ |
| 70 | + --trainer_class_name "nnUNetTrainer_5epochs" \\ |
| 71 | + --export_validation_probabilities true \\ |
| 72 | + --num_gpus 2 |
| 73 | +
|
| 74 | + - find best configuration |
| 75 | +
|
| 76 | + .. code-block:: bash |
| 77 | +
|
| 78 | + python -m monai.apps.nnunet nnUNetRunner find_best_configuration --input "./input.yaml" |
| 79 | +
|
| 80 | + - predict, ensemble, and post-process |
| 81 | +
|
| 82 | + .. code-block:: bash |
| 83 | +
|
| 84 | + python -m monai.apps.nnunet nnUNetRunner predict_ensemble_postprocessing --input "./input.yaml" |
| 85 | +
|
| 86 | +""" |
| 87 | + |
| 88 | + |
| 89 | +from __future__ import annotations |
| 90 | + |
| 91 | +from monai.apps.nnunet.nnunetv2_runner import nnUNetV2Runner |
| 92 | + |
| 93 | +if __name__ == "__main__": |
| 94 | + from monai.utils import optional_import |
| 95 | + |
| 96 | + fire, _ = optional_import("fire") |
| 97 | + fire.Fire({"nnUNetV2Runner": nnUNetV2Runner}) |
0 commit comments