Cooking your first U-Net for Image Segmentation

François Porcher
8 min readJul 7, 2023

Fellow AI cooks, today you are going to learn how to prepare one of the most important recipes in Computer Vision: the U-Net.

You can find the full code on my Github, or on Google Colab

Even better, we are going to apply the U-Net to the MRI segmentation dataset from Kaggle, accessible here:

Ingredients of the Recipe:

  1. Exploration of the Dataset
  2. Creation of the Datasets and Dataloader classes
  3. Creation of the architecture
  4. Examining the losses (DICE and Binary Cross Entropy)
  5. Results
  6. Post-cooking tips to Spice things up!

Exploration of the Dataset

We are given a set of (255 x 255) 2D images of MRI scans, as well as their corresponding masks, where we have to classify each pixel as either 0 (sane), or 1 (tumour).

Here are some examples:

First row: tumour, second row: sane subject

Dataset and DataLoader…

--

--