Skip to content

Tianchi medical AI competition [Season 1]: Lung nodules Caffe deep learning networks. Caffe训练基于卷积神经网络的肺结节分类器

Notifications You must be signed in to change notification settings

JenifferWuUCLA/pulmonary-nodules-deep-networks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deep Learning Tutorial for Pulmonary Nodules Deep Networks, using Caffe

天池医疗AI大赛[第一季]:Caffe训练基于卷积神经网络的肺结节分类器

@author Jeniffer Wu

服务器数据集分布:

Total num TRAIN num TEST num
Caffe 6060 4158 1902

ResNet50 Caffe deep learning loss:

Index Page
Index Page
Index Page

Current config for 8 GPUs with 32 mini-batch size each.

The layer names are designed to match MSRA released pre-trained models to allow for finetuning. You may need to enable/disable bias on conv1 to use these prototxts with some pretrained models.

Running the ResNet-50 as-is gets a few percent lower accuracy than MSRA if done without random reshape & crop.

Pulmonary-nodules-deep-networks relies on external machine learning libraries through a very generic and flexible API. At the moment it has support for:

  • the deep learning library Caffe
  • the deep learning and other usages library Tensorflow

Machine Learning functionalities per library (current):

Training Prediction Classification Object Detection Segmentation Regression Autoencoder
Caffe Y Y Y Y Y Y Y
Tensorflow N Y Y N N N N

GPU support per library

Training Prediction
Caffe Y Y
Tensorflow Y Y

Input data support per library (current):

CSV SVM Text words Text characters Images
Caffe Y Y Y Y Y
Tensorflow N N N N Y

Main functionalities

Pulmonary-nodules-deep-networks implements support for supervised and unsupervised deep learning of images, text and other data, with focus on simplicity and ease of use, test and connection into existing applications. It supports classification, object detection, segmentation, regression, autoencoders, ...

Caffe Dependencies
  • CUDA 8 or 7.5 is recommended for GPU mode.
  • BLAS via ATLAS, MKL, or OpenBLAS.
  • protobuf
  • IO libraries hdf5, leveldb, snappy, lmdb

Tensorflow Dependencies

Caffe version

By default Pulmonary-nodules-deep-networks automatically relies on a modified version of Caffe, https://github.com/beniz/caffe/tree/master This version includes many improvements over the original Caffe, such as sparse input data support, exception handling, class weights, object detection, segmentation, and various additional losses and layers.

Implementation

The code makes use of C++ policy design for modularity, performance and putting the maximum burden on the checks at compile time. The implementation uses many features from C++11.

Models
Caffe Tensorflow Source Top-1 Accuracy (ImageNet)
AlexNet Y N BVLC 57.1%
SqueezeNet Y N DeepScale 59.5%
Inception v1 / GoogleNet Y Y BVLC / Google 67.9%
Inception v2 N Y Google 72.2%
Inception v3 N Y Google 76.9%
Inception v4 N Y Google 80.2%
ResNet 50 Y Y MSR 75.3%
ResNet 101 Y Y MSR 76.4%
ResNet 152 Y Y MSR 77%
Inception-ResNet-v2 N Y Google 79.79%
VGG-16 Y Y Oxford 70.5%
VGG-19 Y Y Oxford 71.3%
ResNext 50 Y N https://github.com/terrychenism/ResNeXt 76.9%
ResNext 101 Y N https://github.com/terrychenism/ResNeXt 77.9%
ResNext 152 Y N https://github.com/terrychenism/ResNeXt 78.7%
DenseNet-121 Y N https://github.com/shicai/DenseNet-Caffe 74.9%
DenseNet-161 Y N https://github.com/shicai/DenseNet-Caffe 77.6%
DenseNet-169 Y N https://github.com/shicai/DenseNet-Caffe 76.1%
DenseNet-201 Y N https://github.com/shicai/DenseNet-Caffe 77.3%
VOC0712 (object detection) Y N https://github.com/weiliu89/caffe/tree/ssd 71.2 mAP

More models:

Templates

Pulmonary-nodules-deep-networks comes with a built-in system of neural network templates (Caffe backend only at the moment). This allows the creation of custom networks based on recognized architectures, for images, text and data, and with much simplicity.

Usage:

  • specify template to use, from mlp, convnet and resnet
  • specify the architecture with the layers parameter:
    • for mlp, e.g. [300,100,10]
    • for convnet, e.g. ["1CR64","1CR128","2CR256","1024","512"], where the main pattern is xCRywhereyis the number of outputs (feature maps),CRstands for Convolution + Activation (withreluas default), andxspecifies the number of chainedCRblocks without pooling. Pooling is applied between allxCRy`
  • for resnets:
    • with images, e.g. ["Res50"] where the main pattern is ResX with X the depth of the Resnet
    • with character-based models (text), use the xCRy pattern of convnets instead, with the main difference that x now specifies the number of chained CR blocks within a resnet block
    • for Resnets applied to CSV or SVM (sparse data), use the mlp pattern. In this latter case, at the moment, the resnet is built with blocks made of two layers for each specified layer after the first one. Here is an example: [300,100,10] means that a first hidden layer of size 300 is applied followed by a resnet block made of two 100 fully connected layer, and another block of two 10 fully connected layers. This is subjected to future changes and more control.

Authors

Pulmonary-nodules-deep-networks is designed and implemented by Yingyi Wu [email protected].

Default build with Caffe

For compiling along with Caffe:

mkdir build
cd build
cmake ..
make

If you are building for one or more GPUs, you may need to add CUDA to your ld path:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64

If you would like to build with cuDNN, your cmake line should be:

cmake .. -DUSE_CUDNN=ON

To target the build of underlying Caffe to a specific CUDA architecture (e.g. Pascal), you can use:

cmake .. -DCUDA_ARCH="-gencode arch=compute_61,code=sm_61"

If you would like a CPU only build, use:

cmake .. -DUSE_CPU_ONLY=ON

If you would like to constrain Caffe to CPU only, use:

cmake .. -DUSE_CAFFE_CPU_ONLY=ON

Build with Tensorflow support

First you must install Bazel and Cmake with version > 3.

And other dependencies:

sudo apt-get install python-numpy swig python-dev python-wheel unzip

If you would like to build with Tensorflow, include the -DUSE_TF=ON paramter to cmake:

cmake .. -DUSE_TF=ON

If you would like to constrain Tensorflow to CPU, use:

cmake .. -DUSE_TF=ON -DUSE_TF_CPU_ONLY=ON

You can combine with XGBoost support with:

cmake .. -DUSE_TF=ON -DUSE_XGBOOST=ON

References

About

Tianchi medical AI competition [Season 1]: Lung nodules Caffe deep learning networks. Caffe训练基于卷积神经网络的肺结节分类器

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published