Code Monkey home page Code Monkey logo

40th_place_solution_aptos2019-blindness-detection's Introduction

APTOS 2019 Blindness Detection: 37th Place(Top 2%) Solution

Aravind Eye Hospital in India provided a large set of retina images taken using fundus photography under a variety of imaging conditions. A clinician has rated each image for the severity of diabetic retinopathy on a scale of 0 to 4. The task of this competition was to train a network that can detect the level of severity.

Our approach

I treated the task as a regression problem. I experimented with several Resnet, SE-Resnet, Resnet, ResNext and SE-Resnext models until I found out that Efficientnet model performs better than most of the pretrained models in this competition. Our final silver winning solution was an ensemble of 5 different Efficientnet models. Here is an overview:

  • Preprocessing: Only Circle Cropping from this kernel.

  • Augmentations: Horizontal and Vertical Flip, 360 rotation, zoom 20%-25%, lighting 50%. Used Fast.ai transformations.

  • Training: Mostly followed this method. Did 5+10 training using 2015 data as train and 2019 as validation set. Then I split the 2019 data into 80:20 ratio using sklearn's Stratified Split function and finetuned the previously trained model over it for 15 epochs. I took the best model based on validation loss which didn't seem to be overfitted and used it for submission. I used a fixed seed so that I can compare different model performances over the same val set. Didn't use CV or TTA. I wrote a pytorch and a fastai version of my codes for the competition.

I mostly used my fastai codes throughout the competition. It requires a lot of work to cleanup my codes and add a detailed explanation of my workflow. I guess I will keep updating this repo.

Approaches That Didn't Work For Me

Classification and Ordinal Regression

Scores (TL;DR)

Here is the summary of my final models and their ensemble scores:

Model Image Size Val Kappa Public Kappa Private Kappa
Efficientnet B2 256 0.922 0.807 0.918
Efficientnet B1 256 0.926 0.804 0.921
Efficientnet B0 256 0.919 0.816 0.914
Efficientnet B3 256 0.921 0.812 0.917
Efficientnet B5 300 0.920 0.802 0.916
Ensemble ---- 0.932 0.826 0.926

Resources

Requirements

  • torch
  • torchvision
  • fastai
  • sklearn
  • numpy
  • tqdm

PyTorch

  • Steps
    • Create a directory data/new_data and keep the 2019 APTOS competition data there.
    • Run cyclic_lr.py and find a suitable learning rate.
    • Run cd pytorch_version and then train.py. It will run a 5 fold cross-validation with 10 epochs for each fold.
    • You can experiment with albumentations augmentations by using DRDatasetAlbumentation as your Dataset class.
    • The code monitors both val_loss and kappa scores and saves model based on them. In my experience, kappa score is unstable and often doesn't seem to be correlated with val_loss. The safe option here is to choose and save your model based on the val_loss only.

Fastai

The notebook fastai_version/Blindness_Detection.ipynb was written for training a model over both 2015 and 2019 datasets. This notebook contains a complete set of instruction and codes from downloading the datasets to train a model in 2 phases.

  • Steps

Will be added soon

40th_place_solution_aptos2019-blindness-detection's People

Contributors

tahsin314 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.