From ac0d1d82b9640bb6bac56bb782a11dda5213e28e Mon Sep 17 00:00:00 2001 From: Wenqi Li <831580+wyli@users.noreply.github.com> Date: Tue, 22 Nov 2022 08:55:29 +0000 Subject: [PATCH] Revert "AutoRunner small updates (#5523)" This reverts commit 72130602340847e15f2042b2bb1b64f6f46eeb93. --- monai/apps/auto3dseg/auto_runner.py | 262 +++++++++++------------ monai/apps/auto3dseg/bundle_gen.py | 58 ++--- monai/apps/auto3dseg/ensemble_builder.py | 48 ++--- monai/apps/auto3dseg/utils.py | 2 +- monai/auto3dseg/algo_gen.py | 7 +- 5 files changed, 184 insertions(+), 193 deletions(-) diff --git a/monai/apps/auto3dseg/auto_runner.py b/monai/apps/auto3dseg/auto_runner.py index f94edca577a..138e751e993 100644 --- a/monai/apps/auto3dseg/auto_runner.py +++ b/monai/apps/auto3dseg/auto_runner.py @@ -14,9 +14,8 @@ import subprocess from copy import deepcopy from time import sleep -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Any, Dict, List, Optional, Union -import numpy as np import torch from monai.apps.auto3dseg.bundle_gen import BundleGen @@ -64,13 +63,14 @@ class AutoRunner: work_dir: working directory to save the intermediate and final results. input: the configuration dictionary or the file path to the configuration in form of YAML. The configuration should contain datalist, dataroot, modality, multigpu, and class_names info. - algos: optionally specify a list of algorithms to use - analyze: on/off switch to run DataAnalyzer and generate a datastats report. Defaults to None, to automatically - decide based on cache, and run data analysis only if we have not completed this step yet. - algo_gen: on/off switch to run AlgoGen and generate templated BundleAlgos. Defaults to None, to automatically - decide based on cache, and run algorithm folders generation only if we have not completed this step yet. - train: on/off switch to run training and generate algorithm checkpoints. Defaults to None, to automatically - decide based on cache, and run training only if we have not completed this step yet. + analyze: on/off switch to run DataAnalyzer and generate a datastats report. If it is set to False, + The AutoRunner will attempt to skip datastats analysis and use cached results. If there is no such cache, + AutoRunner will report an error and stop. + algo_gen: on/off switch to run AlgoGen and generate templated BundleAlgos. If it is set to False, + The AutoRunner will attempt to skip the algorithm generation and stop if there is no cache to load. + train: on/off switch to run training and generate algorithm checkpoints. If it is set to False, + The AutoRunner will attempt to skip the training for all algorithms. If there is zero trained algorithm + but ``train`` is set to False, AutoRunner will stop. hpo: use hyperparameter optimization (HPO) in the training phase. Users can provide a list of hyper-parameter and a search will be performed to investigate the algorithm performances. hpo_backend: a string that indicates the backend of the HPO. Currently, only NNI Grid-search mode @@ -181,69 +181,58 @@ def __init__( self, work_dir: str = "./work_dir", input: Union[Dict[str, Any], str, None] = None, - algos: Optional[Union[Tuple, List]] = None, - analyze: Optional[bool] = None, - algo_gen: Optional[bool] = None, - train: Optional[bool] = None, + analyze: bool = True, + algo_gen: bool = True, + train: bool = True, hpo: bool = False, hpo_backend: str = "nni", ensemble: bool = True, not_use_cache: bool = False, **kwargs, ): - - logger.info(f"AutoRunner using work directory {work_dir}") - os.makedirs(work_dir, exist_ok=True) + if not os.path.isdir(work_dir): + logger.info(f"{work_dir} does not exists. Creating...") + os.makedirs(work_dir) + logger.info(f"{work_dir} created to save all results") + else: + logger.info(f"Work directory {work_dir} is used to save all results") self.work_dir = os.path.abspath(work_dir) self.data_src_cfg_name = os.path.join(self.work_dir, "input.yaml") - self.algos = algos - if input is None and os.path.isfile(self.data_src_cfg_name): - input = self.data_src_cfg_name - logger.info(f"Input config is not provided, using the default {input}") - - if isinstance(input, Dict): + if input is None: + input = os.path.join(self.work_dir, "input.yaml") + elif isinstance(input, Dict): + ConfigParser.export_config_file(input, self.data_src_cfg_name) self.data_src_cfg = input - ConfigParser.export_config_file( - config=input, filepath=self.data_src_cfg_name, fmt="yaml", default_flow_style=None, sort_keys=False - ) elif isinstance(input, str) and os.path.isfile(input): - self.data_src_cfg = ConfigParser.load_config_file(input) - logger.info(f"Loading input config {input}") - if input != self.data_src_cfg_name: - shutil.copy(input, self.data_src_cfg_name) + shutil.copy(input, self.data_src_cfg_name) + logger.info(f"Loading {input} for AutoRunner and making a copy in {self.data_src_cfg_name}") + self.data_src_cfg = ConfigParser.load_config_file(self.data_src_cfg_name) else: - raise ValueError(f"{input} is not a valid file or dict") - - missing_keys = {"dataroot", "datalist", "modality"}.difference(self.data_src_cfg.keys()) - if len(missing_keys) > 0: - raise ValueError(f"Config keys are missing {missing_keys}") - - self.dataroot = self.data_src_cfg["dataroot"] - self.datalist_filename = self.data_src_cfg["datalist"] - self.datastats_filename = os.path.join(self.work_dir, "datastats.yaml") + raise ValueError(f"{input} is not a valid file") self.not_use_cache = not_use_cache self.cache_filename = os.path.join(self.work_dir, "cache.yaml") - self.cache = self.read_cache() + self.cache = self.check_cache() self.export_cache() - # determine if we need to analyze, algo_gen or train from cache, unless manually provided - self.analyze = not self.cache["analyze"] if analyze is None else analyze - self.algo_gen = not self.cache["algo_gen"] if algo_gen is None else algo_gen - self.train = not self.cache["train"] if train is None else train + # Whether we need all the steps or not + self.analyze = self.check_analyze(analyze) + self.algo_gen = self.check_algo_gen(algo_gen) + self.train = self.check_train(train) self.ensemble = ensemble # last step, no need to check # intermediate variables - self.set_num_fold(num_fold=5) + self.dataroot = self.data_src_cfg["dataroot"] + self.datalist_filename = self.data_src_cfg["datalist"] + self.datastats_filename = os.path.join(self.work_dir, "datastats.yaml") self.set_training_params() + self.set_num_fold() self.set_prediction_params() - self.set_analyze_params() - self.save_image = self.set_image_save_transform(kwargs) self.ensemble_method: AlgoEnsemble - self.set_ensemble_method(ensemble_method_name="AlgoEnsembleBestByFold") + self.set_ensemble_method() # hpo if hpo_backend.lower() != "nni": @@ -253,7 +242,7 @@ def __init__( self.search_space: Dict[str, Dict[str, Any]] = {} self.hpo_tasks = 0 - def read_cache(self): + def check_cache(self): """ Check if the intermediate result is cached after each step in the current working directory @@ -262,42 +251,84 @@ def read_cache(self): working directory, the result will be ``empty_cache`` in which all ``has_cache`` keys are set to False. """ - - empty_cache = {"analyze": False, "datastats": None, "algo_gen": False, "train": False} - + empty_cache = { + "analyze": {"has_cache": False, "datastats": None}, + "algo_gen": {"has_cache": False}, + "train": {"has_cache": False}, + } if self.not_use_cache or not os.path.isfile(self.cache_filename): return empty_cache cache = ConfigParser.load_config_file(self.cache_filename) - for k, v in empty_cache.items(): - cache.setdefault(k, v) - - if cache["analyze"]: - if not (isinstance(cache["datastats"], str) and os.path.isfile(cache["datastats"])): + if cache["analyze"]["has_cache"]: + # check if the file in the right format and exists. + if not isinstance(cache["analyze"]["datastats"], str): cache["analyze"] = False - cache["datastats"] = None + cache["analyze"]["datastats"] = None - if cache["algo_gen"]: + if not os.path.isfile(cache["analyze"]["datastats"]): + cache["analyze"]["has_cache"] = False + + if cache["algo_gen"]["has_cache"]: history = import_bundle_algo_history(self.work_dir, only_trained=False) if len(history) == 0: # no saved algo_objects - cache["algo_gen"] = False + cache["algo_gen"]["has_cache"] = False - if cache["train"]: + if cache["train"]["has_cache"]: trained_history = import_bundle_algo_history(self.work_dir, only_trained=True) if len(trained_history) == 0: - cache["train"] = False + cache["train"]["has_cache"] = False return cache - def export_cache(self, **kwargs): + def export_cache(self): """ Save the cache state as ``cache.yaml`` in the working directory """ - self.cache.update(kwargs) - ConfigParser.export_config_file( - self.cache, self.cache_filename, fmt="yaml", default_flow_style=None, sort_keys=False - ) + ConfigParser.export_config_file(self.cache, self.cache_filename, fmt="yaml", default_flow_style=None) + + def check_analyze(self, analyze: bool): + """Check if the AutoRunner can skip data analysis.""" + + if self.cache["analyze"]["has_cache"]: + return False # we can use cached result + + if analyze: + return True # we need to do analysis + else: + raise ValueError( + f"cache data analysis report is not found in {self.work_dir}" + "or the cache.yaml file is missing in the directory" + ) + + def check_algo_gen(self, algo_gen: bool): + """Check if the AutoRunner can skip AlgoGen/BundleGen.""" + + if self.cache["algo_gen"]["has_cache"]: + return False # we can use cached result + + if algo_gen: + return True # we need to do algo_gen + else: + raise ValueError( + f"algo_object.pkl is not found in the task folders under {self.work_dir}" + "or the cache.yaml file is missing in the directory" + ) + + def check_train(self, train: bool): + """Check if the AutoRunner can skip training.""" + + if self.cache["train"]["has_cache"]: + return False # we can use cached result + + if train: + return True # we need to do training + else: + raise ValueError( + f"algo_object.pkl in the task folders under {self.work_dir} has no [best_metrics] key" + "or the cache.yaml file is missing in the directory" + ) def set_num_fold(self, num_fold: int = 5): """ @@ -323,7 +354,10 @@ def set_training_params(self, params: Optional[Dict[str, Any]] = None): {"num_iterations": 8, "num_iterations_per_validation": 4} """ - self.train_params = deepcopy(params) if params is not None else {} + if params is None: + self.train_params = {} + else: + self.train_params = deepcopy(params) def set_prediction_params(self, params: Optional[Dict[str, Any]] = None): """ @@ -338,26 +372,11 @@ def set_prediction_params(self, params: Optional[Dict[str, Any]] = None): For BundleAlgo objects, this set of param will specify the algo ensemble to only inference the first two files in the testing datalist {"file_slices": slice(0, 2)} - """ - self.pred_params = deepcopy(params) if params is not None else {} - - def set_analyze_params(self, params: Optional[Dict[str, Any]] = None): - """ - Set the data analysis extra params. - - Args: - params: a dict that defines the overriding key-value pairs during training. The overriding method - is defined by the algo class. - - Examples: - For BundleAlgo objects, the training parameter to shorten the training time to a few epochs can be - {"num_iterations": 8, "num_iterations_per_validation": 4} - """ if params is None: - self.analyze_params = {"do_ccp": False, "device": "cuda"} + self.pred_params = {"sigmoid": True} # output will be 0-1 else: - self.analyze_params = deepcopy(params) + self.pred_params = deepcopy(params) def set_hpo_params(self, params: Optional[Dict[str, Any]] = None): """ @@ -419,16 +438,15 @@ def set_image_save_transform(self, kwargs): os.makedirs(output_dir) logger.info(f"Directory {output_dir} is created to save ensemble predictions") - self.output_dir = output_dir - output_postfix = kwargs.pop("output_postfix", "ensemble") - output_dtype = kwargs.pop("output_dtype", np.uint8) - resample = kwargs.pop("resample", False) + if "output_postfix" in kwargs: + output_postfix = kwargs.pop("output_postfix") + else: + output_postfix = "ensemble" - return SaveImage( - output_dir=output_dir, output_postfix=output_postfix, output_dtype=output_dtype, resample=resample, **kwargs - ) + self.output_dir = output_dir + return SaveImage(output_dir=output_dir, output_postfix=output_postfix, **kwargs) - def set_ensemble_method(self, ensemble_method_name: str = "AlgoEnsembleBestByFold", **kwargs): + def set_ensemble_method(self, ensemble_method_name: str = "AlgoEnsembleBestN", **kwargs): """ Set the bundle ensemble method @@ -537,26 +555,17 @@ def run(self): """ # step 1: data analysis if self.analyze: - logger.info("Running data analysis...") - da = DataAnalyzer( - self.datalist_filename, self.dataroot, output_path=self.datastats_filename, **self.analyze_params - ) + da = DataAnalyzer(self.datalist_filename, self.dataroot, output_path=self.datastats_filename) da.get_all_case_stats() - self.export_cache(analyze=True, datastats=self.datastats_filename) + self.cache["analyze"]["has_cache"] = True + self.cache["analyze"]["datastats"] = self.datastats_filename + self.export_cache() else: - logger.info("Skipping data analysis...") + logger.info("Found cached results and skipping data analysis...") # step 2: algorithm generation if self.algo_gen: - - if not os.path.isfile(self.datastats_filename): - raise ValueError( - f"Could not find the datastats file {self.datastats_filename}. " - "Possibly the required data analysis step was not completed." - ) - bundle_generator = BundleGen( - algos=self.algos, algo_path=self.work_dir, data_stats_filename=self.datastats_filename, data_src_cfg_name=self.data_src_cfg_name, @@ -565,49 +574,36 @@ def run(self): bundle_generator.generate(self.work_dir, num_fold=self.num_fold) history = bundle_generator.get_history() export_bundle_algo_history(history) - self.export_cache(algo_gen=True) + self.cache["algo_gen"]["has_cache"] = True + self.export_cache() else: - logger.info("Skipping algorithm generation...") + logger.info("Found cached results and skipping algorithm generation...") # step 3: algo training if self.train: history = import_bundle_algo_history(self.work_dir, only_trained=False) - - if len(history) == 0: - raise ValueError( - f"Could not find training scripts in {self.work_dir}. " - "Possibly the required algorithms generation step was not completed." - ) - if not self.hpo: self._train_algo_in_sequence(history) else: self._train_algo_in_nni(history) - self.export_cache(train=True) + self.cache["train"]["has_cache"] = True + self.export_cache() else: - logger.info("Skipping algorithm training...") + logger.info("Found cached results and skipping algorithm training...") # step 4: model ensemble and write the prediction to disks. if self.ensemble: history = import_bundle_algo_history(self.work_dir, only_trained=True) - if len(history) == 0: - raise ValueError( - f"Could not find the trained results in {self.work_dir}. " - "Possibly the required training step was not completed." - ) - builder = AlgoEnsembleBuilder(history, self.data_src_cfg_name) builder.set_ensemble_method(self.ensemble_method) - ensembler = builder.get_ensemble() - preds = ensembler(pred_param=self.pred_params) - if len(preds) > 0: - print("Auto3Dseg picked the following networks to ensemble:") - for algo in ensembler.get_algo_ensemble(): - print(algo[AlgoEnsembleKeys.ID]) - - for pred in preds: - self.save_image(pred) - logger.info(f"Auto3Dseg ensemble prediction outputs are saved in {self.output_dir}.") + preds = ensembler(pred_param=self.pred_params) # apply sigmoid to binarize the prediction + print("Auto3Dseg picked the following networks to ensemble:") + for algo in ensembler.get_algo_ensemble(): + print(algo[AlgoEnsembleKeys.ID]) + + for pred in preds: + self.save_image(pred) + logger.info(f"Auto3Dseg ensemble prediction outputs are saved in {self.output_dir}.") logger.info("Auto3Dseg pipeline is complete successfully.") diff --git a/monai/apps/auto3dseg/bundle_gen.py b/monai/apps/auto3dseg/bundle_gen.py index 65e89aeaf63..6c04b2e7e2f 100644 --- a/monai/apps/auto3dseg/bundle_gen.py +++ b/monai/apps/auto3dseg/bundle_gen.py @@ -177,13 +177,17 @@ def _run_cmd(self, cmd: str, devices_info: str): Execute the training command with target devices information. """ - - logger.info(f"Launching: {cmd}") - ps_environ = os.environ.copy() - if devices_info: - ps_environ["CUDA_VISIBLE_DEVICES"] = devices_info - normal_out = subprocess.run(cmd.split(), env=ps_environ, check=True) - + try: + logger.info(f"Launching: {cmd}") + ps_environ = os.environ.copy() + if devices_info: + ps_environ["CUDA_VISIBLE_DEVICES"] = devices_info + normal_out = subprocess.run(cmd.split(), env=ps_environ, check=True, capture_output=True) + logger.info(repr(normal_out).replace("\\n", "\n").replace("\\t", "\t")) + except subprocess.CalledProcessError as e: + output = repr(e.stdout).replace("\\n", "\n").replace("\\t", "\t") + errors = repr(e.stderr).replace("\\n", "\n").replace("\\t", "\t") + raise RuntimeError(f"subprocess call error {e.returncode}: {errors}, {output}") from e return normal_out def train(self, train_params=None): @@ -248,12 +252,13 @@ def infer(self, image_file): spec.loader.exec_module(infer_class) return infer_class.InferClass(configs_path, *args, **kwargs) - def predict(self, predict_files: list, predict_params=None): + def predict(self, predict_params=None): """ - Use the trained model to predict the outputs with a given input image. + Use the trained model to predict the outputs with a given input image. Path to input image is in the params + dict in a form of {"files", ["path_to_image_1", "path_to_image_2"]}. If it is not specified, then the + prediction will use the test images predefined in the bundle config. Args: - predict_files: a list of paths to files to run inference on ["path_to_image_1", "path_to_image_2"] predict_params: a dict to override the parameters in the bundle config (including the files to predict). """ @@ -262,8 +267,9 @@ def predict(self, predict_files: list, predict_params=None): else: params = deepcopy(predict_params) + files = params.pop("files", ".") inferer = self.get_inferer(**params) - return [inferer.infer(f) for f in ensure_tuple(predict_files)] + return [inferer.infer(f) for f in ensure_tuple(files)] def get_output_path(self): """Returns the algo output paths to find the algo scripts and configs.""" @@ -321,24 +327,24 @@ def __init__(self, algo_path: str = ".", algos=None, data_stats_filename=None, d if isinstance(algos, dict): for algo_name, algo_params in algos.items(): - - template_path = os.path.dirname(algo_params.get("template_path", ".")) - if len(template_path) > 0 and template_path not in sys.path: - sys.path.append(template_path) - try: self.algos.append(ConfigParser(algo_params).get_parsed_content()) except RuntimeError as e: - msg = """Please make sure the folder structure of an Algo Template follows - [algo_name] - ├── configs - │ ├── hyper_parameters.yaml # automatically generated yaml from a set of ``template_configs`` - └── scripts - ├── test.py - ├── __init__.py - └── validate.py - """ - raise RuntimeError(msg) from e + if "ModuleNotFoundError" in str(e): + msg = """Please make sure the folder structure of an Algo Template follows + [algo_name] + ├── configs + │ ├── hyperparameters.yaml # automatically generated yaml from a set of ``template_configs`` + │ ├── network.yaml # automatically generated network yaml from a set of ``template_configs`` + │ ├── transforms_train.yaml # automatically generated yaml to define transforms for training + │ ├── transforms_validate.yaml # automatically generated yaml to define transforms for validation + │ └── transforms_infer.yaml # automatically generated yaml to define transforms for inference + └── scripts + ├── test.py + ├── __init__.py + └── validate.py + """ + raise RuntimeError(msg) from e self.algos[-1].name = algo_name else: self.algos = ensure_tuple(algos) diff --git a/monai/apps/auto3dseg/ensemble_builder.py b/monai/apps/auto3dseg/ensemble_builder.py index 2bcd0e3398e..72ea557dc4e 100644 --- a/monai/apps/auto3dseg/ensemble_builder.py +++ b/monai/apps/auto3dseg/ensemble_builder.py @@ -9,10 +9,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import os from abc import ABC, abstractmethod from copy import deepcopy -from typing import Any, Dict, List, Optional, Sequence, Union +from typing import Any, Dict, List, Optional, Sequence from warnings import warn import numpy as np @@ -20,7 +21,6 @@ from monai.apps.auto3dseg.bundle_gen import BundleAlgo from monai.apps.utils import get_logger from monai.auto3dseg import concat_val_to_np -from monai.auto3dseg.utils import datafold_read from monai.bundle import ConfigParser from monai.transforms import MeanEnsemble, VoteEnsemble from monai.utils.enums import AlgoEnsembleKeys @@ -67,7 +67,7 @@ def get_algo_ensemble(self): """ return self.algo_ensemble - def set_infer_files(self, dataroot: str, data_list_or_path: Union[str, List], data_key: str = "testing"): + def set_infer_files(self, dataroot: str, data_list_file_path: str, data_key: str = "testing"): """ Set the files to perform model inference. @@ -75,29 +75,19 @@ def set_infer_files(self, dataroot: str, data_list_or_path: Union[str, List], da dataroot: the path of the files data_src_cfg_file: the data source file path """ + with open(data_list_file_path) as f: + datalist = json.load(f) - self.infer_files = [] - - if isinstance(data_list_or_path, List): - self.infer_files = data_list_or_path - elif isinstance(data_list_or_path, str): - datalist = ConfigParser.load_config_file(data_list_or_path) - if data_key in datalist: - self.infer_files, _ = datafold_read(datalist=datalist, basedir=dataroot, fold=-1, key=data_key) - else: - logger.info(f"Datalist file has no testing key - {data_key}. No data for inference is specified") - - else: - raise ValueError("Unsupported parameter type") + for d in datalist[data_key]: + self.infer_files.append({"image": os.path.join(dataroot, d["image"])}) - def ensemble_pred(self, preds, sigmoid=False): + def ensemble_pred(self, preds, sigmoid=True): """ ensemble the results using either "mean" or "vote" method Args: preds: a list of probability prediction in Tensor-Like format. - sigmoid: use the sigmoid function to threshold probability one-hot map, - otherwise argmax is used. Defaults to False + sigmoid: use the sigmoid function to threshold probability one-hot map. Returns: a tensor which is the ensembled prediction. @@ -123,7 +113,7 @@ def __call__(self, pred_param: Optional[Dict[str, Any]] = None): make prediction on the infer_files[file_slices]. 'mode': ensemble mode. Currently "mean" and "vote" (majority voting) schemes are supported. 'sigmoid': use the sigmoid function (e.g. x>0.5) to convert the prediction probability map to - the label class prediction, otherwise argmax(x) is used. + the label class prediction. Returns: A list of tensors. @@ -134,27 +124,28 @@ def __call__(self, pred_param: Optional[Dict[str, Any]] = None): param = deepcopy(pred_param) files = self.infer_files - - if "infer_files" in param: - files = param.pop("infer_files") - if "files_slices" in param: slices = param.pop("files_slices") - files = files[slices] + files = self.infer_files[slices] if "mode" in param: mode = param.pop("mode") self.mode = look_up_option(mode, supported=["mean", "vote"]) - sigmoid = param.pop("sigmoid", False) + sigmoid = True + if "sigmoid" in param: + sigmoid = param.pop("sigmoid") + sigmoid = look_up_option(sigmoid, supported=[True, False]) outputs = [] - for i, file in enumerate(files): + for i in range(len(files)): print(i) preds = [] + infer_filename = self.infer_files[i] for algo in self.algo_ensemble: infer_instance = algo[AlgoEnsembleKeys.ALGO] - pred = infer_instance.predict(predict_files=[file], predict_params=param) + param.update({"files": [infer_filename]}) + pred = infer_instance.predict(param) preds.append(pred[0]) outputs.append(self.ensemble_pred(preds, sigmoid=sigmoid)) return outputs @@ -257,6 +248,7 @@ class AlgoEnsembleBuilder: builder.set_ensemble_method(BundleAlgoEnsembleBestN(3)) ensemble = builder.get_ensemble() + result = ensemble.predict() """ def __init__(self, history: Sequence[Dict], data_src_cfg_filename: Optional[str] = None): diff --git a/monai/apps/auto3dseg/utils.py b/monai/apps/auto3dseg/utils.py index f031bfde355..82efb309643 100644 --- a/monai/apps/auto3dseg/utils.py +++ b/monai/apps/auto3dseg/utils.py @@ -31,7 +31,7 @@ def import_bundle_algo_history( history = [] - for name in sorted(os.listdir(output_folder)): + for name in os.listdir(output_folder): write_path = os.path.join(output_folder, name) if not os.path.isdir(write_path): diff --git a/monai/auto3dseg/algo_gen.py b/monai/auto3dseg/algo_gen.py index 7c44303a693..1f8f0e11ede 100644 --- a/monai/auto3dseg/algo_gen.py +++ b/monai/auto3dseg/algo_gen.py @@ -9,8 +9,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Optional - from monai.transforms import Randomizable @@ -33,13 +31,12 @@ def train(self, params: dict): """ pass - def predict(self, predict_files: list, predict_params: Optional[dict] = None): + def predict(self, params: dict): """ Read test data and output model predictions. Args: - predict_files: list of files for the predicting pipeline. - predict_params: key-value pairs of input parameters for the predicting pipeline. + params: key-value pairs of input parameters for the predicting pipeline. """ pass