2D UNet Image Segmentation for HipMRI dataset #269
Open
shans-cloud wants to merge 13 commits intoshakes76:topic-recognitionfrom
Open
2D UNet Image Segmentation for HipMRI dataset #269shans-cloud wants to merge 13 commits intoshakes76:topic-recognitionfrom
shans-cloud wants to merge 13 commits intoshakes76:topic-recognitionfrom
Conversation
- `to_channels()` for one-hot encoding segmentation labels. - `load_data_2D()` for loading and normalising 2D MRI slices. - Code sourced from appendix reference of task sheet.
…slices - Implemented PyTorch Dataset class to load HipMRI study 2D Nifti slice data - Handles normalisation, and binary mask preprocessing for segmentation
- Added skimage.transform.resize for consistent 256x128 input size - Denormalised images before showing sample visualisations
- Changed prostate mask to correctly identify prostate region (label 5) - Added .permute(1, 2, 0) for (C, H, W) format - Removed ImageNet normalisation to preserve grayscale MRI intensity - Removed redundant tensor casts - Cleaned imports and removed visualisation
- Replaced ImageNet based normalisation with min-max scaling for grayscale slices - Added show_epoch_predictions() for visualising 3 model outputs per epoch - Implemented plot_loss() to track training loss over epochs - Added save_model_checkpoint() and load_model_checkpoint() to allow model states to be reloaded - Removed unused function denormalise_image()
- Added DoubleConv class combining two 3x3 Conv2D layers with BatchNorm, ReLU and Dropout - Implemented full UNet model for 2D prostate MRI segmentation. It includes: - Encoder (downsampling), bottleneck, and decoder (upsampling with skip connections) - Outputs sigmoid-activated probability maps in the [0, 1] range for binary segmentation
…d v2 transforms - Added Image and Mask wrappers for transform - Removed hardcoded prostate-only binary mask conversion
- Changed out_channels to 6 for multi-class prediction - Removed final sigmoid activated to output logits for CrossEntropy/Focal compatibility - Reduced feature depth for faster convergence - Updated model docstrings
…ovements - Updated to_channels() for fixed 6 class one hot encoding - Rewrote show_epoch_predictions() for multi-class predictions and Dice per class 5 - Added validation loss plotting and per-class Dice curve visualisation - Improved checkpointing functions
…e Loss - Includes data loading, augmentation, training and validation loops - Adds checkpointing, loss plotting and Dice per class visualisation - Uses combined Focal Dice Loss for class imbalance handling
- Evaluates trained model on test dataset using Dice metric - Outputs per-class Dice, Dice mean and Dice loss summary - Saves qualitative prediction visualisations
|
This is an initial inspection, no action is required at this point 2D UNet – Prostate MRI Segmentation → Easy
• Discussion: None provided. This is needed. Suggestions/Notes:
|
Collaborator
Marking
Marked as per the due date and changes after which aren't necessarily allowed to contribute to grade for fairness. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a finalised codebase for the 2D U-Net segmentation project on the HipMRI dataset. It includes full training, prediction, dataset handling, and utility modules.
Key components:
Notes: