Skip to content

Commit 77015e8

Browse files
ReqweyKumoLiu
andauthored
Fix(2d_segmentation): Restore the predicted value of seg image to the range of 0~225 before saving it (#1951)
### Description To fix the problem that evaluation output images are all black because `post_trans` scale their pixel values to 0~1. ### Checks <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [ ] Avoid including large-size files in the PR. - [ ] Clean up long text outputs from code cells in the notebook. - [ ] For security purposes, please check the contents and remove any sensitive info such as user names and private key. - [ ] Ensure (1) hyperlinks and markdown anchors are working (2) use relative paths for tutorial repo files (3) put figure and graphs in the `./figure` folder - [ ] Notebook runs automatically `./runner.sh -t <path to .ipynb file>` Signed-off-by: Rekawiia Lin <[email protected]> Co-authored-by: YunLiu <[email protected]>
1 parent d948baa commit 77015e8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

2d_segmentation/torch/unet_evaluation_array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def main(tempdir):
4747
val_loader = DataLoader(val_ds, batch_size=1, num_workers=1, pin_memory=torch.cuda.is_available())
4848
dice_metric = DiceMetric(include_background=True, reduction="mean", get_not_nans=False)
4949
post_trans = Compose([Activations(sigmoid=True), AsDiscrete(threshold=0.5)])
50-
saver = SaveImage(output_dir="./output", output_ext=".png", output_postfix="seg")
50+
saver = SaveImage(output_dir="./output", output_ext=".png", output_postfix="seg", scale=255)
5151
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5252
model = UNet(
5353
spatial_dims=2,

2d_segmentation/torch/unet_evaluation_dict.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def main(tempdir):
6161
val_loader = DataLoader(val_ds, batch_size=1, num_workers=4, collate_fn=list_data_collate)
6262
dice_metric = DiceMetric(include_background=True, reduction="mean", get_not_nans=False)
6363
post_trans = Compose([Activations(sigmoid=True), AsDiscrete(threshold=0.5)])
64-
saver = SaveImage(output_dir="./output", output_ext=".png", output_postfix="seg")
64+
saver = SaveImage(output_dir="./output", output_ext=".png", output_postfix="seg", scale=255)
6565
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
6666
model = UNet(
6767
spatial_dims=2,

0 commit comments

Comments
 (0)