From d0d129246f3759f88bc0c23488e819cbac263889 Mon Sep 17 00:00:00 2001 From: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> Date: Fri, 17 May 2024 20:48:31 +0800 Subject: [PATCH] Restrict Auto3DSeg fold input based on datalist (#7778) Fixes #7777. ### Description Lower the maximum `num_fold` allowed for user inputs in Auto3DSeg AutoRunner ### Types of changes - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [x] In-line docstrings updated. Signed-off-by: Mingxin Zheng Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- monai/apps/auto3dseg/auto_runner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monai/apps/auto3dseg/auto_runner.py b/monai/apps/auto3dseg/auto_runner.py index 05c961f999..5b6b501555 100644 --- a/monai/apps/auto3dseg/auto_runner.py +++ b/monai/apps/auto3dseg/auto_runner.py @@ -499,8 +499,8 @@ def set_num_fold(self, num_fold: int = 5) -> AutoRunner: if num_fold <= 0: raise ValueError(f"num_fold is expected to be an integer greater than zero. Now it gets {num_fold}") - if num_fold > self.max_fold + 1: - # Auto3DSeg allows no validation set, so the maximum fold number is max_fold + 1 + if num_fold > self.max_fold: + # Auto3DSeg must contain validation set, so the maximum fold number is max_fold. raise ValueError( f"num_fold is greater than the maximum fold number {self.max_fold} in {self.datalist_filename}." )