Giter Site home page Giter Site logo

joemah / detecting-melanoma-fairly Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pbevan1/detecting-melanoma-fairly

0.0 0.0 0.0 7.25 MB

Implementation for MICCAI DART paper: 'Detecting Melanoma Fairly: Skin Tone Detection and Debiasing for Skin Lesion Classification'

Python 95.27% R 4.73%

detecting-melanoma-fairly's Introduction

Detecting Melanoma Fairly: Skin Tone Detection and Debiasing for Skin Lesion Classification [PDF]

Method:

"Convolutional Neural Networks have demonstrated dermatologist-level performance in the classification of melanoma and other skin lesions, but performance disparities between differing skin tones is an issue that should be addressed before widespread deployment. In this work, we look to tackle skin tone bias in melanoma classification. We propose a simple algorithm for automatically labelling the skin tone of lesion images, and use this to annotate the benchmark ISIC dataset. We subsequently use two leading bias unlearning techniques [2] [3] to mitigate skin tone bias. Our experimental results provide evidence that our skin tone detection algorithm outperforms existing solutions and that unlearning skin tone improves generalisation and can reduce the performance disparity between lighter and darker skin tones [4]."

[Bevan and Atapour-Abarghouei, 2021]



Usage

Software used (see requirements.txt for package requirements)

Python 3.9.6

CUDA Version 11.3

Nvidia Driver Version: 465.31

PyTorch 1.8.1


Downloading data

A free account must be created to download The Interactive Atlas of Dermoscopy, available at this link: https://derm.cs.sfu.ca/Download.html. Place the release_v0.zip file into the data/raw_images directory (see below), from which it will be processed by the download.py script. The other datasets will be automatically downloaded and processed by the download.py script.

Melanoma-Bias  
└───Data
│   └───csv
│   |   │   asan.csv
│   |   │   atlas.csv
│   |   │   ...
│   |
|   └───images
|   |
|   └───raw_images
|       |   release_v0.zip
|
...

Run download.py to download, crop and resize the ISIC, ASAN, MClass clinical, MClass dermoscopic and Fitzpatrick17k datasaets. Have patience as it may take around an hour to complete. The 256x256 resized images are automatically placed into data/images as shown below. The manually downloaded Atlas data (data/raw_images/release_v0.zip) will also be processed by this script. Note this script clears the data/images directory before populating it, so if you want to put other images in there, do this after running the download.py script.

The data directory should now look as follows:

Melanoma-Bias  
└───Data
│   └───csv
│   |   │   asan.csv
│   |   │   atlas.csv
│   |   │   ...
│   |
|   └───images
|       |   asan_256
|       |   atlas_256
|       |   fitzpatrick17k_256
|       |   isic_19_train_256
|       |   isic_20_train_256
|       |   MClassC_256
|       |   MClassD_256
|
...

If you do wish to manually download the datasets, they are available at the following links:

ISIC 2020 data: https://www.kaggle.com/cdeotte/jpeg-melanoma-256x256
ISIC 2019/2018/2017 data: https://www.kaggle.com/cdeotte/jpeg-isic2019-256x256
Interactive Atlas of Dermoscopy: https://derm.cs.sfu.ca/Welcome.html
ASAN Test set: https://figshare.com/articles/code/Caffemodel_files_and_Python_Examples/5406223
MClassC/MClassD: https://skinclass.de/mclass/


Training and evaluation

Training commands for the main experiments from the paper are below. Please see arguments.py for the full range of arguments if you wish to devise alternative experiments. Test results (plots, logs and weights) will autosave into the results directory, in subdirectories specific to the test number. Please contact me if you require trained weights for any model in the report.

Some useful arguments to tweek the below commands:

  • Adjust --CUDA_VISIBLE_DEVICES and num-workers to suit the available GPUs and CPU cores respectively on your machine.
  • To run in debug mode add --DEBUG (limits epochs to 3 batches)
  • To rerun with different random seeds, use --seed argument
  • To run on different architechtures, use --arch argument to choose from resnext101, enet, resnet101, densenet or inception (default=resnext101)
  • Add --cv to perform cross validation
  • Add --test-only if you wish to load weights and run testing only (loads weights of whatever --test-no argument is passed).

Unlearning skin type when training on Fitzpatrick17k data (trains on types 1&2 skin and tests on types 3&4, and 5&6 skin)

Baseline: python train.py --test-no 13 --n-epochs 30 --sktone --CUDA_VISIBLE_DEVICES 0,1 --dataset Fitzpatrick17k --split-skin-types
LNTL: python train.py --test-no 14 --n-epochs 30 --debias-config LNTL --GRL --sktone --CUDA_VISIBLE_DEVICES 0,1 --dataset Fitzpatrick17k --split-skin-types
TABE: python train.py --test-no 15 --n-epochs 30 --debias-config TABE --sktone --CUDA_VISIBLE_DEVICES 0,1 --dataset Fitzpatrick17k --split-skin-types
CLGR: python train.py --test-no 16 --n-epochs 30 --debias-config TABE --GRL --sktone --CUDA_VISIBLE_DEVICES 0,1 --dataset Fitzpatrick17k --split-skin-types

Pre labelled skin types are provided in data/csv/isic_train_20-19-18-17.csv, but if you wish to run the labelling algorithm, run preprocessing.py.

Unlearning skin type when training on full ISIC data

Baseline: python train.py --test-no 17 --n-epochs 4 --sktone --CUDA_VISIBLE_DEVICES 0,1
LNTL: python train.py --test-no 18 --n-epochs 4 --debias-config LNTL --GRL --sktone --CUDA_VISIBLE_DEVICES 0,1 --num-aux 6
TABE: python train.py --test-no 19 --n-epochs 4 --debias-config TABE --sktone --CUDA_VISIBLE_DEVICES 0,1 --num-aux 6
CLGR: python train.py --test-no 20 --n-epochs 4 --debias-config TABE --GRL --sktone --CUDA_VISIBLE_DEVICES 0,1 --num-aux 6

Reference:

Detecting Melanoma Fairly: Skin Tone Detection and Debiasing for Skin Lesion Classification (P. Bevan, A. Atapour-Abarghouei) [pdf]

@misc{bevan2022detecting,
      title={Detecting Melanoma Fairly: Skin Tone Detection and Debiasing for Skin Lesion Classification}, 
      author={Peter J. Bevan and Amir Atapour-Abarghouei},
      year={2022},
      eprint={2202.02832},
      archivePrefix={arXiv},
      primaryClass={eess.IV}
}

detecting-melanoma-fairly's People

Contributors

pbevan1 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.