Skip to content

Commit d763ca2

Browse files
mingxin-zhengwyli
andauthored
update template hash (#5146)
Signed-off-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> Fixes # . ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> Signed-off-by: Wenqi Li <wenqil@nvidia.com> Co-authored-by: Wenqi Li <wenqil@nvidia.com> Co-authored-by: Wenqi Li <831580+wyli@users.noreply.github.com>
1 parent 57d4609 commit d763ca2

File tree

6 files changed

+44
-32
lines changed

6 files changed

+44
-32
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ Integration tests with minimal requirements are deployed to ensure this strategy
193193
To add new optional dependencies, please communicate with the core team during pull request reviews,
194194
and add the necessary information (at least) to the following files:
195195
- [setup.cfg](https://github.com/Project-MONAI/MONAI/blob/dev/setup.cfg) (for package's `[options.extras_require]` config)
196-
- [docs/requirements.txt](https://github.com/Project-MONAI/MONAI/blob/dev/docs/requirements.txt) (pip requirements.txt file)
196+
- [requirements-dev.txt](https://github.com/Project-MONAI/MONAI/blob/dev/requirements-dev.txt) (pip requirements file)
197+
- [docs/requirements.txt](https://github.com/Project-MONAI/MONAI/blob/dev/docs/requirements.txt) (docs pip requirements file)
197198
- [environment-dev.yml](https://github.com/Project-MONAI/MONAI/blob/dev/environment-dev.yml) (conda environment file)
198199
- [installation.md](https://github.com/Project-MONAI/MONAI/blob/dev/docs/source/installation.md) (documentation)
199200

docs/source/apps.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,6 @@ Applications
214214
`auto3dseg`
215215
-----------
216216

217-
.. automodule:: monai.apps.auto3dseg.data_analyzer
217+
.. automodule:: monai.apps.auto3dseg
218218
:members:
219219
:imported-members:

monai/apps/auto3dseg/auto_runner.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ class AutoRunner:
4545
An interface for handling Auto3Dseg with minimal inputs and understanding of the internal states in Auto3Dseg.
4646
The users can run the Auto3Dseg with default settings in one line of code. They can also customize the advanced
4747
features Auto3Dseg in a few additional lines. Examples of customization include
48+
4849
- change cross-validation folds
4950
- change training/prediction parameters
5051
- change ensemble methods
5152
- automatic hyperparameter optimization.
5253
5354
The output of the interface is a directory that contains
55+
5456
- data statistics analysis report
5557
- algorithm definition files (scripts, configs, pickle objects) and training results (checkpoints, accuracies)
5658
- the predictions on the testing datasets from the final algorithm ensemble
@@ -92,6 +94,7 @@ class AutoRunner:
9294
- User can also save the input dictionary as a input YAML file and use the following one-liner
9395
9496
.. code-block:: bash
97+
9598
python -m monai.apps.auto3dseg AutoRunner run --input=./input.yaml
9699
97100
- User can specify work_dir and data source config input and run AutoRunner:
@@ -159,7 +162,8 @@ class AutoRunner:
159162
runner.run()
160163
161164
Notes:
162-
Expected results in the work_dir as below.
165+
Expected results in the work_dir as below::
166+
163167
work_dir/
164168
├── algorithm_templates # bundle algo templates (scripts/configs)
165169
├── cache.yaml # Autorunner will automatically cache results to save time
@@ -170,6 +174,7 @@ class AutoRunner:
170174
├── segresnet_0 # network scripts/configs/checkpoints and pickle object of the algo
171175
├── segresnet2d_0 # network scripts/configs/checkpoints and pickle object of the algo
172176
└── swinunetr_0 # network scripts/configs/checkpoints and pickle object of the algo
177+
173178
"""
174179

175180
def __init__(
@@ -360,9 +365,10 @@ def set_prediction_params(self, params: Optional[Dict[str, Any]] = None):
360365
361366
Args:
362367
params: a dict that defines the overriding key-value pairs during prediction. The overriding method
363-
is defined by the algo class.
368+
is defined by the algo class.
364369
365370
Examples:
371+
366372
For BundleAlgo objects, this set of param will specify the algo ensemble to only inference the first
367373
two files in the testing datalist {"file_slices": slice(0, 2)}
368374
@@ -377,6 +383,7 @@ def set_hpo_params(self, params: Optional[Dict[str, Any]] = None):
377383
Set parameters for the HPO module and the algos before the training. It will attempt to (1) override bundle
378384
templates with the key-value pairs in ``params`` (2) chagne the config of the HPO module (e.g. NNI) if the
379385
key is found to be one of:
386+
380387
- "trialCodeDirectory"
381388
- "trialGpuNumber"
382389
- "trialConcurrency"
@@ -417,7 +424,7 @@ def set_image_save_transform(self, kwargs):
417424
418425
Args:
419426
kwargs: image writing parameters for the ensemble inference. The kwargs format follows SaveImage
420-
transform. For more information, check https://docs.monai.io/en/stable/transforms.html#saveimage .
427+
transform. For more information, check https://docs.monai.io/en/stable/transforms.html#saveimage .
421428
422429
"""
423430

@@ -473,8 +480,8 @@ def _train_algo_in_sequence(self, history: List[Dict[str, Any]]):
473480
474481
Note:
475482
The final results of the model training will be written to all the generated algorithm's output
476-
folders under the working directory. The results include the model checkpoints, a
477-
progress.yaml, accuracies in CSV and a pickle file of the Algo object.
483+
folders under the working directory. The results include the model checkpoints, a
484+
progress.yaml, accuracies in CSV and a pickle file of the Algo object.
478485
"""
479486
for task in history:
480487
for _, algo in task.items():
@@ -493,12 +500,13 @@ def _train_algo_in_nni(self, history):
493500
494501
Note:
495502
The final results of the model training will not be written to all the previously generated
496-
algorithm's output folders. Instead, HPO will generate a new algo during the searching, and
497-
the new algo will be saved under the working directory with a different format of the name.
498-
For example, if the searching space has "learning_rate", the result of HPO will be written to
499-
a folder name with original task name and the param (e.g. "dints_0_learning_rate_0.001").
500-
The results include the model checkpoints, a progress.yaml, accuracies in CSV and a pickle
501-
file of the Algo object.
503+
algorithm's output folders. Instead, HPO will generate a new algo during the searching, and
504+
the new algo will be saved under the working directory with a different format of the name.
505+
For example, if the searching space has "learning_rate", the result of HPO will be written to
506+
a folder name with original task name and the param (e.g. "dints_0_learning_rate_0.001").
507+
The results include the model checkpoints, a progress.yaml, accuracies in CSV and a pickle
508+
file of the Algo object.
509+
502510
"""
503511
default_nni_config = {
504512
"trialCodeDirectory": ".",

monai/apps/auto3dseg/bundle_gen.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from monai.utils import ensure_tuple
2929

3030
logger = get_logger(module_name=__name__)
31-
ALGO_HASH = os.environ.get("MONAI_ALGO_HASH", "f76fb58")
31+
ALGO_HASH = os.environ.get("MONAI_ALGO_HASH", "004a63c")
3232

3333
__all__ = ["BundleAlgo", "BundleGen"]
3434

@@ -39,7 +39,7 @@ class BundleAlgo(Algo):
3939
4040
``BundleAlgo.cfg`` is a ``monai.bundle.ConfigParser`` instance.
4141
42-
..code-block:: python
42+
.. code-block:: python
4343
4444
from monai.apps.auto3dseg import BundleAlgo
4545
@@ -215,26 +215,26 @@ def get_score(self, *args, **kwargs):
215215
def get_inferer(self, *args, **kwargs):
216216
"""
217217
Load the InferClass from the infer.py. The InferClass should be defined in the template under the path of
218-
"scripts/infer.py". It is required to define the "InferClass" (name is fixed) with two functions at least
219-
("__init__" and "infer"). The init class has an override kwargs that can be used to override parameters in
218+
`"scripts/infer.py"`. It is required to define the "InferClass" (name is fixed) with two functions at least
219+
(``__init__`` and ``infer``). The init class has an override kwargs that can be used to override parameters in
220220
the run-time optionally.
221221
222222
Examples:
223223
224-
..code-block:: python
224+
.. code-block:: python
225225
226-
class InferClass
227-
def __init__(self, config_file: Optional[Union[str, Sequence[str]]] = None, **override):
228-
# read configs from config_file (sequence)
229-
# set up transforms
230-
# set up model
231-
# set up other hyper parameters
232-
return
226+
class InferClass
227+
def __init__(self, config_file: Optional[Union[str, Sequence[str]]] = None, **override):
228+
# read configs from config_file (sequence)
229+
# set up transforms
230+
# set up model
231+
# set up other hyper parameters
232+
return
233233
234-
@torch.no_grad()
235-
def infer(self, image_file):
236-
# infer the model and save the results to output
237-
return output
234+
@torch.no_grad()
235+
def infer(self, image_file):
236+
# infer the model and save the results to output
237+
return output
238238
239239
"""
240240
infer_py = os.path.join(self.output_path, "scripts", "infer.py")

monai/apps/auto3dseg/ensemble_builder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ class AlgoEnsembleBuilder:
243243
244244
Examples:
245245
246-
..code-block:: python
246+
.. code-block:: python
247+
247248
builder = AlgoEnsembleBuilder(history, data_src_cfg)
248249
builder.set_ensemble_method(BundleAlgoEnsembleBestN(3))
249250
ensemble = builder.get_ensemble()

monai/apps/auto3dseg/hpo_gen.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class NNIGen(HPOGen):
7070
and supports saving to and loading from pickle files via ``algo_from_pickle`` and ``algo_to_pickle``.
7171
params: a set of parameter to override the algo if override is supported by Algo subclass.
7272
73-
Examples:
73+
Examples::
74+
7475
The experiment will keep generating new folders to save the model checkpoints, scripts, and configs if available.
7576
├── algorithm_templates
7677
│ └── unet
@@ -245,7 +246,8 @@ class OptunaGen(HPOGen):
245246
and supports saving to and loading from pickle files via ``algo_from_pickle`` and ``algo_to_pickle``.
246247
params: a set of parameter to override the algo if override is supported by Algo subclass.
247248
248-
Examples:
249+
Examples::
250+
249251
The experiment will keep generating new folders to save the model checkpoints, scripts, and configs if available.
250252
├── algorithm_templates
251253
│ └── unet

0 commit comments

Comments
 (0)