diff --git a/monai/apps/nnunet/nnunetv2_runner.py b/monai/apps/nnunet/nnunetv2_runner.py index db00929e71..5d5c82801a 100644 --- a/monai/apps/nnunet/nnunetv2_runner.py +++ b/monai/apps/nnunet/nnunetv2_runner.py @@ -596,16 +596,13 @@ def train_single_model_command( if self.export_validation_probabilities: cmd.append("--npz") - store_true_flags = {"c", "val", "use_compressed", "disable_checkpointing"} for _key, _value in kwargs.items(): - if _key in store_true_flags: + prefix = "-" if _key in {"p", "pretrained_weights"} else "--" + if isinstance(_value, bool): if _value: - cmd.append(f"--{_key}") - elif _key in {"p", "pretrained_weights"}: - if _value: - cmd += [f"-{_key}", str(_value)] + cmd.append(f"{prefix}{_key}") else: - cmd += [f"--{_key}", str(_value)] + cmd += [f"{prefix}{_key}", str(_value)] cmd_str: list[str] = [str(c) for c in cmd]