This implementation is inspired by zhixuhao/unet). It uses modern Keras (2.2.5) and tensorflow (2.0RC).
From the major dependencies project requires Keras and Tensorflow. Installation quick guides:
Create virtual environment and install requires packages.
pip install -r requirements.txt
It might be needed to install requirements as user (add --user
flag to pip)
Run main.py
and you will see the predicted results of test image in data/membrane/test. Alternatively you can follow notebook trainUnet.ipnb
The goal is to train the network to distinguish different parts of input image, in other words to perform segmentation. The approach used here is to train deep neural network to conduct segmentation task. The network architecture is U-Net as proposed in: U-Net: Convolutional Networks for Biomedical Image Segmentation.
The experiments were conducted on dataset from isbi challenge. He is how the input data looks like:
*Figure 1. Input image that needs segmentation.* *Figure 2. Labels for training - in black pixels considered as boundaries.*The input data for the training is the 30 images which is much too less to train the neural network. To proceed, available data was transformed in different ways to produce new samples that can be used for training. Note, that is labeling data need to be transformed in the same way as input image (features).
Data augmentation
The data for training contains 30 images 512x512 pixels each. Fortunately, this is quite common problem in deep learning for computer vision and Keras module ImageDataGenerator
in keras.preprocessing.image
has already functions to make different kinds of transformations.
Data augmentation - resulting samples
This deep neural network is implemented with Keras functional API, which makes it extremely easy to experiment with different interesting architectures.
Output from the network is a 512x512 which represents mask that should be learned. Sigmoid activation function makes sure that mask pixels are in [0, 1] range.
-
The model is trained for 5 epochs. After 5 epochs, calculated accuracy is about 0.97.
-
Loss function for the training is a binary crossentropy.
Use the trained model to do segmentation on test images, the result is statisfactory.
- Olaf Ronneberger, Philipp Fischer, Thomas Brox for Unet Convolutional Network
- implementation is heavily inspired by: zhixuhao