About the Example MoNuSeg Dataset
from https://monuseg.grand-challenge.org: Training data containing 30 images and around 22,000 nuclear boundary annotations has been released to the public previously as a dataset article in IEEE Transactions on Medical imaging in 2017.
- The train dataset (images and annotations) can be downloaded from https://drive. google.com/file/d/1ZgqFJomqQGNnsx7w7QBzQQMVA16lbVCA/view
- Test set images with additional 7000 nuclear boundary annotations are available here MoNuSeg 2018 Testing data. Please cite the following papers if you use the training and testing datasets of this challenge: The test dataset can be downloaded from https://drive.google.com/file/d/1NKkSQ5T0ZNQ8aUhh0a8Dt2YKYCQXIViw/view
How to download and preprocess the data can be found in the corresponding Notebook.
!pip install -Uqq deepflash2
import numpy as np
from deepflash2.all import *
from pathlib import Path
Prior to training and predicting directorys need to be specified and parameters need to be set. For convenience exissting Google Drive folders can be used.
# Connect to drive
try:
from google.colab import drive
drive.mount('/gdrive')
except:
print('Google Drive is not available.')
SEED = 0 # We used seeds [0,1,2] in our experiemnts
OUTPUT_PATH = Path("/content/predictions") # Save predictions here
MODEL_PATH = Path("/content/models") # Save models here
TRAINED_MODEL_PATH= Path('/gdrive/MyDrive/deepflash2-paper/models/')
DATA_PATH = Path('/gdrive/MyDrive/deepflash2-paper/data')
#################### Parameters ####################
DATASET = 'monuseg'
mask_directory='masks_preprocessed'
# Datasets have different numbers of classes - 2 in case of monuseg
num_classes = 2
# Diameters are calculated using the median sizes from the respective training sets - 21 in case of monuseg
diameter = 21
# Create deepflash2 config class
cfg = Config(random_state=SEED,
num_classes=num_classes, scale= 1.)
Data preprocessing
- Initialize
EnsembleLearner
- Plot images and masks to show if they are correctly loaded
train_data_path = DATA_PATH/DATASET/'train'
ensemble_path = MODEL_PATH/DATASET/f'{SEED+1}'
el = EnsembleLearner(image_dir='images',
mask_dir=mask_directory,
config=cfg,
path=train_data_path,
ensemble_path=ensemble_path)
el.ds.show_data(max_n=2)