This repository contains utilities for virtual slides and images classification and semantic segmentation with Keras and Caffe and an extension class of ImageDataGenerator of Keras to generate batches of images with data augmentation for segmentation.
Demo code is provided for reference.
Python 2.7
OpenCV 3.4
Numpy 1.14
Tensorflow 1.7
Keras 2.1
OpenSlide 1.1
Caffe 0.15 (optional)
slide_demo.py It shows an example of using the Keras or Caffe model to segment a whole virtual slide or classify slide in grid and saving the results.
image_demo.py It shows an example of using the Keras or Caffe model to segment or classify images from a folder and saving the results.
train_segmentation_demo.py It shows an example of training a segmentation model from scratch.
See comments or use help for detailed function usage.
An extension of ImageDataGenerator of Keras for semgentation images iteration , with similiar api of flow_from_directory.
The structure of the image directory would be like:
"directory"
├── "image_subfolder"
│ ├── image1.png
│ ├── image2.png
│ └── ...
└── "mask_subfolder"
├── image1.png
├── image2.png
└── ...
Virtual slide class (Slideobject) for retrieving image batches and results reconstruction.
-
retrieve_tiles_to_queue_threadRetrieve image batches and put into a queue waiting for analysis. -
reconstruct_segmentation_queue_to_levelReconstruct segmentation results on top of selected layer image. -
reconstruct_classification_queue_to_levelReconstruct classification results on top of selected layer image. -
preprocess_imgRewrite to include customized image preprocessing. -
gray_codeRewrite based on given code to change color for each category forresult_mask. -
color_codeRewrite based on given code to change color for each category forresult_rgb.
Image class (Imageobject) for retrieving image batches and results reconstruction.
-
retrieve_tiles_to_queue_threadRetrieve image batches and put into a queue waiting for analysis. -
reconstruct_segmentation_queue_to_fileReconstruct segmentation results on top of original image and save. -
reconstruct_classification_queue_to_fileReconstruct classification results on top of original image and save. -
preprocess_imgRewrite to include customized image pre-processing. -
gray_codeRewrite based on given code to change color for each category forresult_mask. -
color_codeRewrite based on given code to change color for each category forresult_rgb.
Caffe class (Caffeobject) for forwarding images batch to neural network.
forward_from_queue_to_queueForward batch in data queue to neural network and put results in result queue.
Tensorflow (Keras) class (TFobject) for forwarding images batch to neural network.
forward_from_queue_to_queueForward batch in data queue to neural network and put results in result queue.
- Semantic Segmentation of Colon Glands in Inflammatory Bowel Disease Biopsies. Z Ma, Z Swiderska-Chadaj, N Ing, H Salemi, D McGovern, B Knudsen, A Gertych. Information Technologies in Biomedicine, Kamień Śląski, Poland, June 2018.

