Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make sure that a custom output folder for cv results is empty #2269

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions nnunetv2/evaluation/find_best_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from copy import deepcopy
from typing import Union, List, Tuple

from batchgenerators.utilities.file_and_folder_operations import load_json, join, isdir, save_json

from batchgenerators.utilities.file_and_folder_operations import (
load_json, join, isdir, listdir, save_json
)
from nnunetv2.configuration import default_num_processes
from nnunetv2.ensembling.ensemble import ensemble_crossvalidations
from nnunetv2.evaluation.accumulate_cv_results import accumulate_cv_results
Expand Down Expand Up @@ -320,6 +321,11 @@ def accumulate_crossval_results_entry_point():
merged_output_folder = join(trained_model_folder, f'crossval_results_folds_{folds_tuple_to_string(args.f)}')
else:
merged_output_folder = args.o
if isdir(merged_output_folder) and len(listdir(merged_output_folder)) > 0:
raise FileExistsError(
f"Output folder {merged_output_folder} exists and is not empty. "
f"To avoid data loss, nnUNet requires an empty output folder."
)

accumulate_cv_results(trained_model_folder, merged_output_folder, args.f)

Expand Down
Loading