Pre-trained models for a Cascaded-FCN in caffe and tensorflow that segments

Overview

Cascaded-FCN

This repository contains the pre-trained models for a Cascaded-FCN in caffe and tensorflow that segments the liver and its lesions out of axial CT images and a python wrapper for dense 3D Conditional Random Fields 3D CRFs.

This work was published in MICCAI 2016 paper (arXiv link) titled :

Automatic Liver and Lesion Segmentation in CT Using Cascaded Fully Convolutional 
Neural Networks and 3D Conditional Random Fields

Caffe

Quick Start

If you want to use our code we offer an docker image, which runs our code and has all dependencies installed including the correct caffe version. After having installed docker and nvidia docker:

sudo GPU=0 nvidia-docker run -v $(pwd):/data -P --net=host --workdir=/Cascaded-FCN -ti --privileged patrickchrist/cascadedfcn bash

And than start jupyter notebook and browse to localhost:8888

jupyter notebook

Tensorflow

Please look at Readme and Documentation at https://github.com/FelixGruen/tensorflow-u-net

Citation

If you have used these models in your research please use the following BibTeX for citation :

@Inbook{Christ2016,
title="Automatic Liver and Lesion Segmentation in CT Using Cascaded Fully Convolutional Neural Networks and 3D Conditional Random Fields",
author="Christ, Patrick Ferdinand and Elshaer, Mohamed Ezzeldin A. and Ettlinger, Florian and Tatavarty, Sunil and Bickel, Marc and Bilic, Patrick and Rempfler, Markus and Armbruster, Marco and Hofmann, Felix and D'Anastasi, Melvin and Sommer, Wieland H. and Ahmadi, Seyed-Ahmad and Menze, Bjoern H.",
editor="Ourselin, Sebastien and Joskowicz, Leo and Sabuncu, Mert R. and Unal, Gozde and Wells, William",
bookTitle="Medical Image Computing and Computer-Assisted Intervention -- MICCAI 2016: 19th International Conference, Athens, Greece, October 17-21, 2016, Proceedings, Part II",
year="2016",
publisher="Springer International Publishing",
address="Cham",
pages="415--423",
isbn="978-3-319-46723-8",
doi="10.1007/978-3-319-46723-8_48",
url="http://dx.doi.org/10.1007/978-3-319-46723-8_48"
}
@ARTICLE{2017arXiv170205970C,
   author = {{Christ}, P.~F. and {Ettlinger}, F. and {Gr{\"u}n}, F. and {Elshaera}, M.~E.~A. and 
	{Lipkova}, J. and {Schlecht}, S. and {Ahmaddy}, F. and {Tatavarty}, S. and 
	{Bickel}, M. and {Bilic}, P. and {Rempfler}, M. and {Hofmann}, F. and 
	{Anastasi}, M.~D and {Ahmadi}, S.-A. and {Kaissis}, G. and {Holch}, J. and 
	{Sommer}, W. and {Braren}, R. and {Heinemann}, V. and {Menze}, B.},
    title = "{Automatic Liver and Tumor Segmentation of CT and MRI Volumes using Cascaded Fully Convolutional Neural Networks}",
  journal = {ArXiv e-prints},
archivePrefix = "arXiv",
   eprint = {1702.05970},
 primaryClass = "cs.CV",
 keywords = {Computer Science - Computer Vision and Pattern Recognition, Computer Science - Artificial Intelligence},
     year = 2017,
}
@inproceedings{Christ2017SurvivalNetPP,
  title={SurvivalNet: Predicting patient survival from diffusion weighted magnetic resonance images using cascaded fully convolutional and 3D convolutional neural networks},
  author={Patrick Ferdinand Christ and Florian Ettlinger and Georgios Kaissis and Sebastian Schlecht and Freba Ahmaddy and Felix Gr{\"{u}n and Alexander Valentinitsch and Seyed-Ahmad Ahmadi and Rickmer Braren and Bjoern H. Menze},
  booktitle={ISBI},
  year={2017}
}

Description

This work uses 2 cascaded UNETs,

  1. In step1, a UNET segments the liver from an axial abdominal CT slice. The segmentation output is a binary mask with bright pixels denoting the segmented object. By segmenting all slices in a volume we obtain a 3D segmentation.
  2. (Optional) We enhance the liver segmentation using 3D dense CRF (conditional random field). The resulting enhanced liver segmentation is then used further for step2.
  3. In step2 another UNET takes an enlarged liver slice and segments its lesions.

The input to both networks is 572x572 generated by applying reflection mirroring at all 4 sides of a 388x388 slice. The boundary 92 pixels are reflecting, resulting in (92+388+92)x(92+388+92) = 572x572.

An illustration of the pipeline is shown below :

Illustration of the CascadedFCN pipeline

For detailed Information have a look in our presentation

3D Conditional Random Field 3DCRF

You can find the 3D CRF at 3DCRF-python. Please follow the installation description in the Readme.

License

These models are published with unrestricted use for research and educational purposes. For commercial use, please refer to the paper authors.

Comments
  • model test problem

    model test problem

    Hi, I have tested your released model, my code is refer to your notebook. my code is

    `caffe.set_mode_gpu() caffe.set_device(2) net_liver = caffe.Net('/home/zhou/zou/Cascaded-FCN/models/cascadedfcn/step1/step1_deploy.prototxt', '/home/zhou/zou/Cascaded-FCN/models/cas cadedfcn/step1/step1_weights.caffemodel', caffe.TEST)

    img=read_dicom_series("../train_image/3Dircadb1.17/PATIENT_DICOM/") lbl=read_liver_lesion_masks("../train_image/3Dircadb1.17/MASKS_DICOM/") S = 90 img_p = step1_preprocess_img_slice(img[...,S]) lbl_p = preprocess_lbl_slice(lbl[...,S]) net_liver.blobs['data'].data[0,0,...] = img_p pred = net_liver.forward()['prob'][0,1] > 0.5 plt.figure(figsize=(3*5,10)) plt.subplot(1, 3, _1) plt.title('CT') plt.imshow(img_p[92:-92,92:-92], 'gray') plt.subplot(1, 3, 2) plt.title('GT') plt.imshow(lbl_p, 'gray') plt.subplot(1, 3, 3) plt.title('pred') plt.imshow(pred, 'gray')`

    but the result is very bad like this result

    opened by manutdzou 19
  • Regarding preprocessing(for step1)

    Regarding preprocessing(for step1)

    Hi, I am having trouble understanding pre-processing step. I have dicom images of liver of size 512x512. How do I proceed further?Do I have to resize it to 388x388 and add symmetrical padding of size 92?

    Any help would be appreciated.

    Thanks.

    opened by cjayanth95 18
  • Example Docker does not work (crashes)

    Example Docker does not work (crashes)

    After I couldn't get the notebook to work on my own caffe installation (see #29) I tried running your prepared docker. However this line

    # Load network
    net1 = caffe.Net(STEP1_DEPLOY_PROTOTXT, STEP1_MODEL_WEIGHTS, caffe.TEST)
    

    throws the following error

    ...
    F0509 19:58:49.805807    24 cudnn_relu_layer.cpp:15] Check failed: status == CUDNN_STATUS_SUCCESS (1 vs. 0)  CUDNN_STATUS_NOT_INITIALIZED
    

    My host system is ubuntu 18.04, NVIDIA Driver Version 390.48, CUDA Version 9.1.85 (if that is any help) caffe is set to CPU mode in your example jupyter notebook

    Any help would be appreciated.

    opened by michaelschwier 6
  • Pretrained TensorFlow Models

    Pretrained TensorFlow Models

    Can you provide the pre-trained tensorflow model(including graph and ckpt) for us? Training from scratch really takes a lot of time and need gpus with big memory. Thank you very much!

    opened by zakizhou 5
  • Result is very worse followed by the ipynb file

    Result is very worse followed by the ipynb file

    Hi, I execute the cascaded_unet_inference.ipynb that doesn't report any questions, but the result is worse. The result of step1 is shown as follow: image

    Any one know the reason? Thank you very much

    opened by UpCoder 3
  • Batch normalization not used? Step2 dataset?

    Batch normalization not used? Step2 dataset?

    Hi, I studied u-net prototxt and your unet-overfit-python.prototxt . I found that you didn't use batch normalization layer. Can you explain why?

    In step1, the dataset contains 15 patients to train liver. And for step2, do you still use these 15 patients' CT scans? You crop the liver and resized and padded to fit the u-net. Then I thought there are two problems: 1, for each slice, liver size is different, if you crop just the tiny liver, comparing with those "big" liver, there will be noises. In Medical image processing, they often crop the liver by the volume size, not the liver size of a single slice. 2, for 15 patients, 2063 slices in total, 1572 of them have livers, and only 579 of them have tumors. You just crop all livers to train lesion in step2? Then will there be imbalance problem?

    opened by PiaoLiangHXD 3
  • training data format

    training data format

    Hi there,

    I was wondering what the format of the data was for you when you did the training of this model? I understand the preprocessing steps for the example, but when the training happened was it loaded in through .npy files? I was trying to figure it out by looking through https://github.com/mohamed-ezz/saratan/blob/master/notebooks/realtime_train.ipynb but was having issues. Thanks for your help.

    opened by idinsmore1 2
  • Input image sizing

    Input image sizing

    Hello!

    If I understand right your input images size is increased from 388x388 to 572x572, the same dimensions as in the U-Net publication by Olaf Ronneberger, by extending all sides with mirrored copies of the image.

    But since the background of the CT scans has intensities near zero anyway, wouldn't it be possible to use zero padding instead and remain at the original size? The network should then be able to use less memory and to return a label map of the same size as the input, so I wonder if you found a reason not to use the zero padding that I have been missing so far.

    opened by mopladin 2
  • Finetune Ultrasound 2D Dataset.

    Finetune Ultrasound 2D Dataset.

    Hi,

    I would like to train my dataset , which consist of ultrasound 2D images, in gray-scale, for making automatic bone segmentation . I have no GPU, so I would like to finetune your model in order to do the training faster . My images are of different sizes( the height is fixed at 512, but the width varies between 300 and 512. Is there any special consideration in this case ? Your cand find attached an example of an image and the ground truth image_01_0541_croped image_01_0541_croped

    Thank you very much,

    Cordially,

    Mateo Villa

    opened by mateovilla2 2
  • How to run 3D CRF?

    How to run 3D CRF?

    Hello,

    I'm trying to reproduce your results and I'm having trouble with the CRF step. Following the ipython notebook, I'm using image 17 from 3DIRCAdb1. I've made some modifications in the notebook to run the network for every slice. Without CRF, I got a dice score of 0.8573.

    I cloned and installed https://github.com/mbickel/DenseInferenceWrapper/. However, I'm not sure how I can use it. I'm trying the following:

    pro = CRFProcessor.CRF3DProcessor()
    result = pro.set_data_and_run(img_preprocessed, extended_labels)
    

    Where img_preprocessed is the preprocessed image without the padding reflections (dimensions (W,H,D); and extended_labels is the output of the predictions (direct probabilities, not thresholded bool) with dimensions (W,H,D,L) (where L = 1). I'm getting a (W,H,D) matrix with zeroes.

    Can you help me with this?

    opened by fabioperez 2
  • Incorrect output after step 1.

    Incorrect output after step 1.

    Hi, I have run the notebook and seemed to obtain an incorrect prediction after step1.

    For comparison, I have used the same example from https://github.com/cjayanth95/liverseg/blob/master/custom_outs_updated.ipynb.

    This is my output: https://github.com/XiaonanZang/liverseg/blob/master/cascaded_unet_inference-Copy1.ipynb.

    I have followed your instruction and built the caffe from the provided git.

    Could you help me on this issue?

    Thank you very much.

    Xiaonan Zang

    opened by XiaonanZang 2
  • How testing and training is done

    How testing and training is done

    On which dataset training is done and also how testing is performed (name of both datasets would be fine)

    Also could you pls highlight the evaluating function

    opened by Shrijeet16 0
  • TypeError: slice indices must be integers or None or have an __index__ method`

    TypeError: slice indices must be integers or None or have an __index__ method`

    Firstly, let me commend you on your effort for this paper and the repo that accompanies it. As a programmer myself, I know how difficult it is to write code especially for machine learning models.

    I successfully, reproduced the results through a GPU hardware and the code code ran up until:

    # Visualize results imshow(img_p, lbl_p, pred>0.5, title=['Slice','Ground truth', 'Prediction'])

    Besides, I also had to downgrade SCIPY to 1:00 because of the depreciated imgresize issue.

    /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:108: DeprecationWarning:imresizeis deprecated!imresizeis deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use ``skimage.transform.resize`` instead. /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:104: DeprecationWarning:imresizeis deprecated!imresizeis deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use ``skimage.transform.resize`` instead.

    perhaps you could look into these issues.

    Additionally, running: `# Prepare liver patch for step2

    net1 output is used to determine the predicted liver bounding box

    img_p2, bbox = step2_preprocess_img_slice(img_p, pred) imshow(img_p2)`

    gave the following error: `--------------------------------------------------------------------------- TypeError Traceback (most recent call last) in () ----> 1 img_p2, bbox = step2_preprocess_img_slice(img_p, pred) 2 imshow(img_p2)

    in step2_preprocess_img_slice(img_p, step1_pred) 79 y2 = min(img.shape[0], y2+y_pad) 80 ---> 81 img = img[y1:y2+1, x1:x2+1] 82 pred = pred[y1:y2+1, x1:x2+1] 83

    TypeError: slice indices must be integers or None or have an index method`

    these affected the rest of the executions such as:

    1. `# Visualize result

    extract liver portion as predicted by net1

    x1,x2,y1,y2 = bbox lbl_p_liver = lbl_p[y1:y2,x1:x2]

    Set labels to 0 and 1

    lbl_p_liver[lbl_p_liver==1]=0 lbl_p_liver[lbl_p_liver==2]=1 imshow(img_p2[92:-92,92:-92],lbl_p_liver, pred2>0.5)`

    1. # Load step2 network net2 = caffe.Net(STEP2_DEPLOY_PROTOTXT, STEP2_MODEL_WEIGHTS, caffe.TEST)

    and finally

    1. net2.blobs['data'].data[0,0,...] = img_p2 pred2 = net2.forward()['prob'][0,1] print (pred2.shape)

    Please could you kindly proffer solutions to these issues?

    opened by tobimichigan 0
  • Issue with prediction method

    Issue with prediction method

    OS: ubuntu 16.04 GPU: Nvidia GeForce GTX 105 The kernel dies while loading network when working from docker and when I set up my own environment I am able to run it through some layers only from net.forward() method but unable to get to the output, the kernel dies on forward pass. kindly suggest how to solve the issue as I am testing it only for one image right now as given in the notebook. Thank you

    screenshot from 2018-07-05 18-33-41

    opened by nerdykamil 0
  • Question:The results for  the code  are error

    Question:The results for the code are error

        1、I downloaded the 3Dircadb database.
        2、I downloaded the Cascaded-FCN code from https://github.com/IBBM/Cascaded-FCN.
        3、I downloaded the step1_weights.caffemodel(https://www.dropbox.com/s/aoykiiuu669igxa/step1_weights.caffemodel?dl=1) and step2_weights.caffemodel(https://www.dropbox.com/s/ql10c37d7ura23l/step2_weights.caffemodel?dl=1).
       I run the cascaded_unet_inference.ipynb in the  Cascaded-FCN code. I find that the prediction is error, so I want to know why。The attachment is result of prediction.
    

    3dircadb

    opened by wwlaoxi 11
  • A question about training sets and metrics

    A question about training sets and metrics

    There are some irrelevant images (without liver region) in the CT volumes. Do I need to remove these images or send all of them to the network as a training set? For metrics, I didn't get any prediction for small image with very small liver region. So some of the metrics cannot be calculated (Infinite). Do you get a predicted result for every single image, and compared with the ground-truth of foreground?

    opened by ginvermouth 0
Owner
null
A collection of pre-trained StyleGAN2 models trained on different datasets at different resolution.

Awesome Pretrained StyleGAN2 A collection of pre-trained StyleGAN2 models trained on different datasets at different resolution. Note the readme is a

Justin 1.1k Dec 24, 2022
Cascaded Pyramid Network (CPN) based on Keras (Tensorflow backend)

ML2 Takehome Project Reimplementing the paper: Cascaded Pyramid Network for Multi-Person Pose Estimation Dataset The model uses the COCO dataset which

Vo Van Tu 1 Nov 22, 2021
Codes to pre-train T5 (Text-to-Text Transfer Transformer) models pre-trained on Japanese web texts

t5-japanese Codes to pre-train T5 (Text-to-Text Transfer Transformer) models pre-trained on Japanese web texts. The following is a list of models that

Kimio Kuramitsu 1 Dec 13, 2021
KoRean based ELECTRA pre-trained models (KR-ELECTRA) for Tensorflow and PyTorch

KoRean based ELECTRA (KR-ELECTRA) This is a release of a Korean-specific ELECTRA model with comparable or better performances developed by the Computa

null 12 Jun 3, 2022
An e-commerce company wants to segment its customers and determine marketing strategies according to these segments.

customer_segmentation_with_rfm Business Problem : An e-commerce company wants to

Buse Yıldırım 3 Jan 6, 2022
Implementation for the "Surface Reconstruction from 3D Line Segments" paper.

Surface Reconstruction from 3D Line Segments Surface reconstruction from 3d line segments. Langlois, P. A., Boulch, A., & Marlet, R. In 2019 Internati

null 85 Jan 4, 2023
Chunkmogrify: Real image inversion via Segments

Chunkmogrify: Real image inversion via Segments Teaser video with live editing sessions can be found here This code demonstrates the ideas discussed i

David Futschik 112 Jan 4, 2023
The original weights of some Caffe models, ported to PyTorch.

pytorch-caffe-models This repo contains the original weights of some Caffe models, ported to PyTorch. Currently there are: GoogLeNet (Going Deeper wit

Katherine Crowson 9 Nov 4, 2022
Face Detection and Alignment using Multi-task Cascaded Convolutional Networks (MTCNN)

Face-Detection-with-MTCNN Face detection is a computer vision problem that involves finding faces in photos. It is a trivial problem for humans to sol

Chetan Hirapara 3 Oct 7, 2022
Cascaded Deep Video Deblurring Using Temporal Sharpness Prior and Non-local Spatial-Temporal Similarity

This repository is the official PyTorch implementation of Cascaded Deep Video Deblurring Using Temporal Sharpness Prior and Non-local Spatial-Temporal Similarity

hippopmonkey 4 Dec 11, 2022
QueryDet: Cascaded Sparse Query for Accelerating High-Resolution SmallObject Detection

QueryDet-PyTorch This repository is the official implementation of our paper: QueryDet: Cascaded Sparse Query for Accelerating High-Resolution Small O

Chenhongyi Yang 276 Dec 31, 2022
Photographic Image Synthesis with Cascaded Refinement Networks - Pytorch Implementation

Photographic Image Synthesis with Cascaded Refinement Networks-Pytorch (https://arxiv.org/abs/1707.09405) This is a Pytorch implementation of cascaded

Soumya Tripathy 63 Mar 27, 2022
Pre-trained BERT Models for Ancient and Medieval Greek, and associated code for LaTeCH 2021 paper titled - "A Pilot Study for BERT Language Modelling and Morphological Analysis for Ancient and Medieval Greek"

Ancient Greek BERT The first and only available Ancient Greek sub-word BERT model! State-of-the-art post fine-tuning on Part-of-Speech Tagging and Mor

Pranaydeep Singh 22 Dec 8, 2022
High level network definitions with pre-trained weights in TensorFlow

TensorNets High level network definitions with pre-trained weights in TensorFlow (tested with 2.1.0 >= TF >= 1.4.0). Guiding principles Applicability.

Taehoon Lee 1k Dec 13, 2022
Tensorflow Implementation for "Pre-trained Deep Convolution Neural Network Model With Attention for Speech Emotion Recognition"

Tensorflow Implementation for "Pre-trained Deep Convolution Neural Network Model With Attention for Speech Emotion Recognition" Pre-trained Deep Convo

Ankush Malaker 5 Nov 11, 2022
Another pytorch implementation of FCN (Fully Convolutional Networks)

FCN-pytorch-easiest Trying to be the easiest FCN pytorch implementation and just in a get and use fashion Here I use a handbag semantic segmentation f

Y. Dong 158 Dec 21, 2022
Another pytorch implementation of FCN (Fully Convolutional Networks)

FCN-pytorch-easiest Trying to be the easiest FCN pytorch implementation and just in a get and use fashion Here I use a handbag semantic segmentation f

Y. Dong 158 Dec 21, 2022
Source code and dataset for ACL2021 paper: "ERICA: Improving Entity and Relation Understanding for Pre-trained Language Models via Contrastive Learning".

ERICA Source code and dataset for ACL2021 paper: "ERICA: Improving Entity and Relation Understanding for Pre-trained Language Models via Contrastive L

THUNLP 75 Nov 2, 2022