Need help with kaggle_diabetic?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

224 Stars 118 Forks MIT License 174 Commits 9 Opened issues


Team o_O solution for the Kaggle Diabetic Retinopathy Detection Challenge

Services available


Need anything else?

Contributors list

# 184,153
156 commits

Kaggle Diabetic Retinopathy Detection


Extract train/test images to

respectively and put the
file into the
directory as well.

Install python2 dependencies via,

pip install -r requirements.txt
You need a CUDA capable GPU with at least 4GB of video memory and CUDNN installed.

If you'd like to run a deterministic variant you can use the

branch. Note that the branch has its own
file. In order to achieve determinism cuda-convnet is used for convolutions instead of cuDNN. The deterministic version increases the GPU memory requirements to 6GB and takes about twice as long to run.

The project was developed and tested on arch linux and hardware with a i7-2600k CPU, GTX 970 and 980Ti GPUs and 32 GB RAM. You probably need at least 8GB of RAM as well as up to 160 GB of harddisk space (for converted images, network parameters and extracted features) to run all the code in this repository.


Generating the kaggle solution

A commented bash script to generate our final 2nd place solution can be found in

Running all the commands sequentially will probably take 7 - 10 days on recent consumer grade hardware. If you have multiple GPUs you can speed things up by doing training and feature extraction for the two networks in parallel. However, due to the computationally heavy data augmentation it may be far less than twice as fast especially when working with 512x512 pixel input images.

You can also obtain a quadratic weighted kappa score of 0.839 on the private leaderboard by just training the 4x4 kernel networks and by performing only 20 feature extraction iterations with the weights that gave you the best MSE validation scores during training. The entire ensemble only achieves a slightly higher score of 0.845.


All these python scripts can be invoked with

to display a brief help message. They are meant to be executed in the order,
    crops and resizes images
    trains convolutional networks
    extracts features from trained convolutional networks
    blends features, optionally blending inputs from both patient eyes

Example usage:

python --crop_size 128 --convert_directory data/train_tiny --extension tiff --directory data/train
python --crop_size 128 --convert_directory data/test_tiny --extension tiff --directory data/test
``` Usage: [OPTIONS]

Options: --directory TEXT Directory with original images. [default: data/train] --convertdirectory TEXT Where to save converted images. [default: data/trainres] --test Convert images one by one and examine them on screen. [default: False] --crop_size INTEGER Size of converted images. [default: 256] --extension TEXT Filetype of converted images. [default: tiff] --help Show this message and exit ```

Example usage:

python --cnf configs/
python --cnf configs/ --weights_from weigts/c_256_5x5_32/weights_final.pkl
``` Usage: [OPTIONS]

Options: --cnf TEXT Path or name of configuration module. [default: configs/] --weightsfrom TEXT Path to initial weights file. --help Show this message and exit. ```

Example usage:

python --cnf config/ --train --test --n_iter 5
python --cnf config/ --n_iter 5 --test_dir path/to/other/image/files
python --test_dir path/to/alternative/test/files
``` Usage: [OPTIONS]

Options: --cnf TEXT Path or name of configuration module. [default: configs/] --niter INTEGER Iterations for test time averaging. [default: 1] --skip INTEGER Number of test time averaging iterations to skip. [default: 0] --test Extract features for test set. Ignored if --testdir is specified. [default: False] --train Extract features for training set. [default: False] --weightsfrom TEXT Path to weights file. --test_dir TEXT Override directory with test set images. --help Show this message and exit. ```

Example usage: ``` python --perpatient # use configuration in blend.yml python --perpatient --featurefile path/to/feature/file python --perpatient --test_dir path/to/alternative/test/files

Usage: [OPTIONS]

Options: --cnf TEXT Path or name of configuration module. [default: configs/] --predict Make predictions on test set features after training. [default: False] --perpatient Blend features of both patient eyes. [default: False] --featuresfile TEXT Read features from specified file. --niter INTEGER Number of times to fit and average. [default: 1] --blendcnf TEXT Blending configuration file. [default: blend.yml] --testdir TEXT Override directory with test set images. --help Show this message and exit. ```


  • The convolutional network configuration is done via the files in the
  • To select different combinations of extracted features for blending edit
  • To tune parameters related to blending edit
  • To make predictions for a different test set either
    • put the resized images into the
    • or edit the
      field in your config file(s) inside the
    • or pass the
      --test_dir /path/to/test/files
      argument to

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.