Skip to content

Commit

Permalink
Add training script
Browse files Browse the repository at this point in the history
  • Loading branch information
hermancollin committed Nov 8, 2023
1 parent 19e0c50 commit e0c321c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions nnunet_scripts/run_5fold_cross_validation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
#
# Training nnUNetv2 on multiple folds
#
# NOTE: This is a template script, modify it as needed
#
# Authors: Naga Karthik, Jan Valosek
#

# !!! MODIFY THE FOLLOWING VARIABLES ACCORDING TO YOUR NEEDS !!!
config=2d # e.g. 3d_fullres or 2d
dataset_id=002 # e.g. 301
dataset_name=Dataset002_TEM # e.g Dataset301_XXX
nnunet_trainer="nnUNetTrainer"

# Select number of folds here
folds=(0 1 2)
# folds=(0)

echo "-------------------------------------------------------"
echo "Running preprocessing and verifying dataset integrity"
echo "-------------------------------------------------------"

nnUNetv2_plan_and_preprocess -d ${dataset_id} --verify_dataset_integrity

for fold in ${folds[@]}; do
echo "-------------------------------------------"
echo "Training on Fold $fold"
echo "-------------------------------------------"

# training
CUDA_VISIBLE_DEVICES=2 nnUNetv2_train ${dataset_id} ${config} ${fold} -tr ${nnunet_trainer}

echo ""
echo "-------------------------------------------"
echo "Training completed, Testing on Fold $fold"
echo "-------------------------------------------"

# inference
CUDA_VISIBLE_DEVICES=2 nnUNetv2_predict -i ${nnUNet_raw}/${dataset_name}/imagesTs -tr ${nnunet_trainer} -o ${nnUNet_results}/${nnunet_trainer}__nnUNetPlans__${config}/fold_${fold}/test -d ${dataset_id} -f ${fold} -c ${config}

echo ""
echo "-------------------------------------------"
echo " Inference completed on Fold $fold"
echo "-------------------------------------------"

done

0 comments on commit e0c321c

Please sign in to comment.