-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from axondeepseg/feature/add_ensemble_experiments
Ensembling Experiment Support Added
- Loading branch information
Showing
3 changed files
with
58 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# The first argument should be the path to the nnunet folder. | ||
# The remaining arguments should be the names of the datasets to process. | ||
NNUNET_PATH=$1 | ||
DATASET_NAME="Dataset444_AGG" | ||
|
||
shift | ||
for dataset in "$@"; do | ||
echo -e "\n\nRun inference with ${NNUNET_PATH}/nnUNet_results/${dataset} model on $DATASET_NAME dataset\n\n" | ||
dataset_name=${dataset#Dataset???_} | ||
|
||
# Run inference and save the probabilities | ||
python nnunet_scripts/run_inference.py --path-dataset ${NNUNET_PATH}/nnUNet_raw/${DATASET_NAME}/imagesTs \ | ||
--path-out ${NNUNET_PATH}/nnUNet_results/${DATASET_NAME}/ensemble_models/${dataset_name}_model_best_checkpoints_inference_with_probabilities \ | ||
--path-model ${NNUNET_PATH}/nnUNet_results/${dataset}/nnUNetTrainer__nnUNetPlans__2d/ \ | ||
--use-gpu \ | ||
--use-best-checkpoint \ | ||
--save-probabilities | ||
done | ||
|
||
folders=() | ||
ensemble_name="ensemble" | ||
for dataset in "$@"; do | ||
dataset_name=${dataset#Dataset???_} | ||
folders+=("${NNUNET_PATH}/nnUNet_results/${DATASET_NAME}/ensemble_models/${dataset_name}_model_best_checkpoints_inference_with_probabilities") | ||
ensemble_name+="_${dataset_name}" | ||
done | ||
|
||
# Ensemble the inference results with nnUNetv2_ensemble | ||
nnUNetv2_ensemble -i ${folders[@]} -o ${NNUNET_PATH}/nnUNet_results/${DATASET_NAME}/ensemble_models/${ensemble_name}_model_best_checkpoints_inference | ||
|
||
# Evaluate the ensemble model | ||
python nnunet_scripts/run_evaluation.py --pred_path ${NNUNET_PATH}/nnUNet_results/${DATASET_NAME}/ensemble_models/${ensemble_name}_model_best_checkpoints_inference \ | ||
--mapping_path ${NNUNET_PATH}/nnUNet_raw/${DATASET_NAME}/fname_mapping.json \ | ||
--gt_path ${NNUNET_PATH}/test_labels \ | ||
--output_fname ${NNUNET_PATH}/nnUNet_results/${DATASET_NAME}/ensemble_models/scores/${ensemble_name}_model_best_checkpoints_scores \ | ||
--pred_suffix _0000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters