hub icon indicating copy to clipboard operation
hub copied to clipboard

The example code for u-net brain MRI may not include normalization pre-step

Open Anonymousjoy opened this issue 4 years ago • 2 comments

When I following the example code in [(https://pytorch.org/hub/mateuszbuda_brain-segmentation-pytorch_unet/)] the results is a mess. Then I discovered by removing the normalization step, everything goes well. I checked the repo for the original code, it seems the training procedure did not have a normalization step. So it may be better to fix it. The model is good. What I mean is, changing preprocess = transforms.Compose([ transforms.ToTensor(), transforms.Normalize(mean=m, std=s), ]) to preprocess = transforms.Compose([ transforms.ToTensor(), ]) I was new to this area, tell me if I am wrong. Thanks.

Anonymousjoy avatar Dec 03 '19 23:12 Anonymousjoy

@mateuszbuda would you mind taking a quick look? Thanks!

ailzhang avatar Dec 03 '19 23:12 ailzhang

@Anonymousjoy Thanks for trying my model. You're right that the example code does not produce correct segmentations due to a simplification in the normalization step. The reason for this is that the model was trained to perform segmentation of 3D MRI volumes by concatenating predictions for 2D slices. The example code only shows how to forward one 2D slice. The normalization step requires the entire volume which I didn't want to upload on GitHub for the sake of data size. Here is a link to normalization function that works on volumes: https://github.com/mateuszbuda/brain-segmentation-pytorch/blob/8ef2e2d423b67b53ec8113fc71a9b968bb0f66e7/utils.py#L77

mateuszbuda avatar Dec 24 '19 11:12 mateuszbuda