Please cite our papr if you find the code useful.
N. Zhang, et al. A Spatially Constrained Deep Convolutional Neural Network for Nerve Fiber Segmentation in Corneal Confocal Microscopic Images Using Inaccurate Annotations, International Symposium on Biomedical Imaging, 2020. In press.
Paper preprint is available here: https://arxiv.org/abs/2004.09443
A video presentation is available here: https://youtu.be/yOSiodu9mo8
A CCM segmentation and quantification software is available in : http://www.cs.nott.ac.uk/~pszxc/
Contact xin.chen@nottingham.ac.uk
In this code, we only included a few example CCM images for testing the code."example_train.py" is the main function to train the model.
Semantic image segmentation is one of the most important tasks in medical image analysis. Most state-of-the-art deep learning methods require a large number of accurately annotated examples for model training. However, accurate annotation is difficult to obtain especially in medical applications. In this paper, we propose a spatially constrained deep convolutional neural network (DCNN) to achieve smooth and robust image segmentation using inaccurately annotated labels for training. In our proposed method, image segmentation is formulated as a graph optimization problem that is solved by a DCNN model learning process. The cost function to be optimized consists of a unary term that is calculated by cross entropy measurement and a pairwise term that is based on enforcing a local label consistency. The proposed method has been evaluated based on corneal confocal microscopic (CCM) images for nerve fiber segmentation, where accurate annotations are extremely difficult to be obtained. Based on both the quantitative result of a synthetic dataset and qualitative assessment of a real dataset, the proposed method has achieved superior performance in producing high quality segmentation results even with inaccurate labels for training.
-
Install 64-bit python 3.7.5 for windows or other 64-bit versions (select pip as an optional feature),
-
Install NumPy, and Tensorflow 2.0 with GPU from PyPI:
pip install --upgrade pip pip install --upgrade Numpy pip install --upgrade tensorflow-gpu
-
Install CUDA 10.0.
-
Download cuDNN and copy the files (bin, include, lib) from
*\cuda\
toC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\
. -
Test Tensorflow 2.0:
import tensorflow as tf hello = tf.constant("hello TensorFlow!") print (hello)
-
install and update Anaconda
# move to local folder mkdir -p $HOME/usr/local/ cd $HOME/usr/local # download and install Anaconda (if not installed) wget "https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh" bash Anaconda3-2019.10-Linux-x86_64.sh # remove install file rm Anaconda3-2019.10-Linux-x86_64.sh # update Anaconda conda update --all
-
Create conda environment for tensorflow
conda create --name tf2_gpuenv
-
Activate the environment and install tensorflow-gpu
# activate tensorflow environment conda activate tf2_gpuenv # install python 3.7 package (include pip) conda install python=3.7 # install tensorflow-gpu use pip pip install --upgrade tensorflow-gpu # install cuda 10.0 and cudnn conda install cudatoolkit=10.0 conda install cudnn
-
Choosing GPUs
# check available gpus nvidia-smi # choose gpu [n] export CUDA_VISIBLE_DEVICES=[n]
-
Test tensorflow2 gpu version in python
import tensorflow as tf hello = tf.constant("hello TensorFlow!") print (hello)
pip install --upgrade numpy, sklearn, scipy
pip install --upgrade opencv-python
pip install --upgrade Pillow
pip install --upgrade nibabel
pip install --upgrade shutil