ad
ad

Unet Brain-MRI-Segmentation | TensorFlow | Computer Vision | Deep Learning | Kaggle | Medical Image

Education


Introduction

Introduction

Hello, my name is Rohan Paul, and welcome to my Computer Vision and Deep Learning YouTube channel! In today's session, we'll have a code-along session to implement a U-Net architecture using TensorFlow and Keras for Brain MRI segmentation.

Dataset Overview

The dataset is from Kaggle, titled "Brain MRI Segmentation," and is approximately 1.06 GB in size. It consists of brain MRI images along with manually created masks that highlight FLAIR abnormalities. The dataset includes images from 110 patients who are part of the Cancer Genome Atlas Lower Grade Glioma collection.

Data Structure

The dataset folders follow a specific structure:

  • Each top-level folder represents a single patient.
  • Each patient folder contains around 20 .tif images.
  • Each .tif image has a corresponding mask image named with an '_mask' suffix.

Data Preprocessing

We start by loading the dataset, splitting the images and masks into separate lists, and then creating a DataFrame for the training, validation, and test sets. Data augmentation and normalization functions are also defined to prepare the data for training.

U-Net Architecture

The U-Net architecture consists of an encoder (contracting path) and a decoder (expanding path) with skip connections between corresponding layers.

Encoder Path

The encoder path performs down-sampling and feature extraction using a sequence of convolutional and max-pooling layers.

Decoder Path

The decoder path up-samples the image to its original size and concatenates the up-sampled features with the corresponding features from the encoder path.

Final Model Compilation

The model is compiled using the Adam optimizer, a Dice coefficient loss function, and additional metrics including IOU, Dice coefficient, and binary accuracy.

Training the U-Net

The model is trained using the prepared data generators for a specified number of epochs. The training results, including loss and accuracy, are logged and plotted.

Evaluation on Test Set

The trained model is evaluated on the test set, and various metrics like test loss, IOU, and Dice coefficient are calculated.

Visualization of Results

The predicted masks from the test set are visualized alongside the original images and their corresponding masks. The output shows promising results with clear segmentation of the tumor regions.