From 74d3d9b76aa2b5cdf9cd599e0550ee4edd5bf115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=81=ABRekawiia=20Lin?= <50829219+Reqwey@users.noreply.github.com> Date: Mon, 10 Mar 2025 00:24:38 +0800 Subject: [PATCH] Fix(2d_segmentation): Restore the predicted value of seg image to the range of 0~225 before saving it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: âĞRekawiia Lin --- 2d_segmentation/torch/unet_evaluation_array.py | 2 +- 2d_segmentation/torch/unet_evaluation_dict.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/2d_segmentation/torch/unet_evaluation_array.py b/2d_segmentation/torch/unet_evaluation_array.py index b071bfba25..7113204e35 100644 --- a/2d_segmentation/torch/unet_evaluation_array.py +++ b/2d_segmentation/torch/unet_evaluation_array.py @@ -47,7 +47,7 @@ def main(tempdir): val_loader = DataLoader(val_ds, batch_size=1, num_workers=1, pin_memory=torch.cuda.is_available()) dice_metric = DiceMetric(include_background=True, reduction="mean", get_not_nans=False) post_trans = Compose([Activations(sigmoid=True), AsDiscrete(threshold=0.5)]) - saver = SaveImage(output_dir="./output", output_ext=".png", output_postfix="seg") + saver = SaveImage(output_dir="./output", output_ext=".png", output_postfix="seg", scale=255) device = torch.device("cuda" if torch.cuda.is_available() else "cpu") model = UNet( spatial_dims=2, diff --git a/2d_segmentation/torch/unet_evaluation_dict.py b/2d_segmentation/torch/unet_evaluation_dict.py index 8cf723abe1..f3e1bb934d 100644 --- a/2d_segmentation/torch/unet_evaluation_dict.py +++ b/2d_segmentation/torch/unet_evaluation_dict.py @@ -61,7 +61,7 @@ def main(tempdir): val_loader = DataLoader(val_ds, batch_size=1, num_workers=4, collate_fn=list_data_collate) dice_metric = DiceMetric(include_background=True, reduction="mean", get_not_nans=False) post_trans = Compose([Activations(sigmoid=True), AsDiscrete(threshold=0.5)]) - saver = SaveImage(output_dir="./output", output_ext=".png", output_postfix="seg") + saver = SaveImage(output_dir="./output", output_ext=".png", output_postfix="seg", scale=255) device = torch.device("cuda" if torch.cuda.is_available() else "cpu") model = UNet( spatial_dims=2,