From 32f8adbfa280c811aca2505fa3876b75650f0171 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Sat, 28 Mar 2020 00:43:42 +0000 Subject: [PATCH] fixes integration test (missing original affine) (#223) --- examples/segmentation_3d/unet_evaluation_dict.py | 1 - examples/segmentation_3d_ignite/unet_evaluation_dict.py | 4 +--- tests/test_integration_segmentation_3d.py | 6 ++---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/examples/segmentation_3d/unet_evaluation_dict.py b/examples/segmentation_3d/unet_evaluation_dict.py index 6aeb7b5d3d..2c1ced8aff 100644 --- a/examples/segmentation_3d/unet_evaluation_dict.py +++ b/examples/segmentation_3d/unet_evaluation_dict.py @@ -88,7 +88,6 @@ metric_sum += value.sum().item() val_outputs = (val_outputs.sigmoid() >= 0.5).float() saver.save_batch(val_outputs, {'filename_or_obj': val_data['img.filename_or_obj'], - 'original_affine': val_data['img.original_affine'], 'affine': val_data['img.affine']}) metric = metric_sum / metric_count print('evaluation metric:', metric) diff --git a/examples/segmentation_3d_ignite/unet_evaluation_dict.py b/examples/segmentation_3d_ignite/unet_evaluation_dict.py index 0aabbcb426..8af11d5e10 100644 --- a/examples/segmentation_3d_ignite/unet_evaluation_dict.py +++ b/examples/segmentation_3d_ignite/unet_evaluation_dict.py @@ -100,9 +100,7 @@ def _sliding_window_processor(engine, batch): # convert the necessary metadata from batch data SegmentationSaver(output_path='tempdir', output_ext='.nii.gz', output_postfix='seg', name='evaluator', batch_transform=lambda batch: {'filename_or_obj': batch['img.filename_or_obj'], - 'original_affine': batch['img.original_affine'], - 'affine': batch['img.affine'], - }, + 'affine': batch['img.affine']}, output_transform=lambda output: predict_segmentation(output[0])).attach(evaluator) # the model was trained by "unet_training_dict" exmple CheckpointLoader(load_path='./runs/net_checkpoint_50.pth', load_dict={'net': net}).attach(evaluator) diff --git a/tests/test_integration_segmentation_3d.py b/tests/test_integration_segmentation_3d.py index 6d997ad5f0..b0cb8bfe78 100644 --- a/tests/test_integration_segmentation_3d.py +++ b/tests/test_integration_segmentation_3d.py @@ -203,10 +203,8 @@ def run_inference_test(root_dir, device=torch.device("cuda:0")): metric_sum += value.sum().item() val_outputs = (val_outputs.sigmoid() >= 0.5).float() saver.save_batch( - val_outputs, { - 'filename_or_obj': val_data['img.filename_or_obj'], 'original_affine': - val_data['img.original_affine'], 'affine': val_data['img.affine'] - }) + val_outputs, + {'filename_or_obj': val_data['img.filename_or_obj'], 'affine': val_data['img.affine']}) metric = metric_sum / metric_count return metric