Skip to content

Rishi625/Image-Segmentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Workflow:

  1. Data Preparation:

    • Loading Data: Load the grayscale images and corresponding labels from the provided directories (DATA/samples and DATA/labels).
    • Normalization: Normalize the pixel values of images and labels to bring them within a common scale, typically between 0 and 1. This ensures stable training and consistent behavior across different datasets.
    • Dataset Splitting: Split the dataset into training and validation sets to assess model performance. Common splitting ratios include 80-20 or 70-30 for training and validation, respectively.
  2. Model Development:

    • UNet Architecture: Implement the UNet architecture, which consists of an encoder-decoder network with skip connections. This architecture is well-suited for semantic segmentation tasks, including membrane centerline detection.
    • Custom Dataset Class: Define a custom dataset class to handle loading and preprocessing of data. This class should inherit from PyTorch's Dataset class and implement methods like __len__ and __getitem__ for data access.
    • Transformations: Define transformations such as resizing, normalization, and conversion to tensors using torchvision.transforms. These transformations ensure data consistency and compatibility with the model.
    • Data Loaders: Initialize data loaders for training and validation datasets. Data loaders provide batch-wise access to the dataset, enabling efficient training with mini-batch gradient descent.
  3. Training:

    • Device Configuration: Determine the device for computation based on availability (GPU or CPU). Use torch.device to set the device accordingly.
    • Loss Function Selection: Choose an appropriate loss function for the task. For membrane centerline detection, Binary Cross-Entropy Loss (BCELoss) is commonly used as it measures the similarity between predicted and ground truth masks.
    • Optimizer Initialization: Initialize an optimizer (Adam) to update the model parameters during training. Set the learning rate, which controls the step size of parameter updates.
    • Learning Rate Scheduler: Optionally, set up a learning rate scheduler to dynamically adjust the learning rate during training based on validation performance. This helps improve convergence and prevent overfitting.
    • Training Loop: Iterate over the training dataset for multiple epochs. Within each epoch, iterate over mini-batches of data, compute the loss, backpropagate gradients, and update model parameters using the optimizer.
    • Model Checkpointing: save the model weights periodically (after every few epochs) to resume training or evaluate later.
  4. Model Evaluation:

    • Validation Process: Evaluate the trained model on the validation dataset to assess its performance.
    • Loss and Metrics Calculation: Compute the validation loss and additional evaluation metrics such as pixel accuracy, Intersection over Union (IoU), and Dice coefficient. These metrics provide insights into the model's ability to accurately detect membrane centerlines.
  5. Inference:

    • Load Pre-trained Model: Load the pre-trained weights of the UNet model.
    • Prepare Input Data: Load or preprocess the new input images for membrane centerline detection.
    • Perform Inference: Pass the input images through the model to obtain predictions.

Choice of UNet Architecture

The UNet architecture is chosen for several reasons:

  1. Semantic Segmentation: UNet is well-suited for semantic segmentation tasks where pixel-level classification is required. In this case, we need to classify each pixel as membrane or background.

  2. U-Shape Architecture: UNet's U-shaped architecture allows for capturing both local and global features through skip connections. This is beneficial for detecting membrane centerlines, as it requires understanding both local details and overall structure.

  3. Encoder-Decoder Design: UNet's encoder-decoder design enables effective feature extraction and reconstruction, making it suitable for tasks where input and output sizes may differ.

  4. Previous Success: UNet has been widely used and proven effective in various medical image segmentation tasks, including membrane detection. Its popularity and success in similar domains make it a suitable choice for this task as well.

About

Image segmentation of brain cell images using U-Net

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors