Giter VIP home page Giter VIP logo

retfound_mae's Introduction

RETFound - A Playground for Pushing EyeCare Bounds

This is not the official repo for RETFound: a foundation model for generalizable disease detection from retinal images, which is based on MAE: (Or Keras version implemented by Yuka Kihara can be found here)

This is a repo for playing with RETFound.

Currently, it supports:

  • Fine-tuning RETFound on your own data
  • Using the wonderful Transformer-MM-Explainability Repo by @hila-chefer to explain the predictions of RETFound
  • An attempt at using the retfound weights to train a Color Fundus Photo (cfp) to Fluorescein Angiography (FA) encoder-decoder model

()

Key features of RETFound

  • RETFound is pre-trained on 1.6 million retinal images with self-supervised learning
  • RETFound has been validated in multiple disease detection tasks
  • RETFound can be efficiently adapted to customised tasks

Install environment

Before you do anything else, you need to get a clean environment set up.

  1. Create environment with conda:
conda create -n retfound python=3.7.5 -y
conda activate retfound
  1. Install dependencies
git clone https://github.com/beswift/RETFound_MAE.git
cd RETFound_MAE
pip install -r requirements.txt

Fine-Tuning with your own data using the retfound weights

To fine tune RETFound on your own data:
Did you follow the steps above to get your environment set up? Do that first!

1. Download the RETFound pre-trained weights

ViT-Large
Colour fundus image download
OCT download
  1. Organise your images into folders so that each folder is the name of the "class" the images belong to, like:
├── data
│   ├── class_1
│   │   ├── image_1.jpg
│   │   ├── image_2.jpg
│   │   ├── image_3.jpg
│   ├── class_2
│   │   ├── image_1.jpg
│   │   ├── image_2.jpg
│   │   ├── image_3.jpg
│   ├── class_3
│   │   ├── image_1.jpg
│   │   ├── image_2.jpg
│   │   ├── image_3.jpg
  1. In a terminal, run the following command to start fine-tuning (use IDRiD as example). A fine-tuned checkpoint will be saved during training. Evaluation will be run after training.
python train.py
  1. To evaluate the fine-tuned model, run the following command:
python test.py

Using the Retfound weights to train a Color Fundus Photo (cfp) to Fluorescein Angiography (FA) encoder-decoder model

To train a cfp to FA encoder-decoder model using the retfound weights:
Did you follow the steps above to get your environment set up? Do that first!

  1. Download the retfound weights
  2. Organise your images into folders so that each folder is the name of the "class" the images belong to, like:
├── data
│   ├── cfp
│   │   ├── image_1.jpg
│   │   ├── image_2.jpg
│   │   ├── image_3.jpg
│   ├── fa
|   |   ├── image_1.jpg
│   │   ├── image_2.jpg
│   │   ├── image_3.jpg
  1. In a terminal, run the following command to start training:
python leaky.py
  1. To evaluate the model, run the following command:
python leakyTest.py


See the original README for more details on how to use the base retfound scripts

Citation

If you find the RETFound repository useful, please consider citing this paper:

@article{zhou2023foundation,
  title={A foundation model for generalizable disease detection from retinal images},
  author={Zhou, Yukun and Chia, Mark A and Wagner, Siegfried K and Ayhan, Murat S and Williamson, Dominic J and Struyven, Robbert R and Liu, Timing and Xu, Moucheng and Lozano, Mateo G and Woodward-Court, Peter and others},
  journal={Nature},
  pages={1--8},
  year={2023},
  publisher={Nature Publishing Group UK London}
}

If you find this repo useful, that's amazing and unexpected! If you are interested in working or partnering on eye care, chronic disease or wellness related projects, we'd love to work with you over at Unified Imaging!

retfound_mae's People

Contributors

rmaphoh avatar beswift avatar liutiming avatar epeters3 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.