Skip to content

jamesjjcondon/rad_pl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rad_pl

A pytorch_lightning project template for radiology convolutional neural networks.

The focus here is to expedite you getting started on your own project.

#ArtificialIntelligence #NeuralNetworks #CNNs #HealthAI #Pytorch #PytorchLightning

Prerequisites:

  • git
  • a python installation
  • ability to create virtual environments
  • NVIDIA's CUDA Toolkit if you have and want to use a GPU/graphics card.

Installation:

1. Setup a virtual environment first:

  • use either virtualenv, venv or conda
  • activate it
  • make sure you've got pip

For example with venv:

python -m venv my_environments/rad_pl_env

source my_environments/rad_pl_env/bin/activate

or conda:

conda create --name rad_pl_env

conda activate rad_pl_env and you might need to conda install pip

2. Download the repository:

In a terminal,

  • cd into a folder where you want to create this template

  • type git clone https://github.com/jamesjjcondon/rad_pl.git

  • cd rad_pl

  • pip install -r requirements.txt

3. Adjust constants.py for your folders / directories

Open constants.py and add in your 'machine' / computer name and a directory for DATADIR, then save.

On windows you can use 'vim' from an anaconda prompt or notepad to view and edit. (This makes it easy to move machines and share with colleagues.)

In a terminal, you could also type: python constants.py to prompt an error message with your machine name (to add back into constants.py).

Start training on MedNIST

python train.py

Test out hyperparameters and pytorch_lightning.Trainer flags

Check out the trainer section on pytorch_lightning docs page. Currently: https://pytorch-lightning.readthedocs.io/en/latest/common/trainer.html

Use tensorboard to view learning curves:

tensorboard --logdir '...<your-DATADIR->\logs'

eg tensorboard --logdir C:\Users\James\Documents\rad_pl\logs then open up a browser at htttp://localhost:6006 (or wherever tensorboard tells you to).

Do your own inference and evaluation

Try customising to a different dataset and with different file formats

  • learn to use IPython.embed() to debug! It'll save you a LOT of time.

Dataset - MedNIST:

MedNIST is made available by Dr. Bradley J. Erickson M.D., Ph.D. (Department of Radiology, Mayo Clinic) under the Creative Commons CC BY-SA 4.0 license.

If you use the MedNIST dataset, please acknowledge the source. It originates and sizes have been standardised from:

Please see the relevant terms of use:

The scripts here, as is, are simply classifiying the images' modality into these classes:

  • Abdomen CT
  • Breast MRI
  • Chest X-ray
  • Chest CT
  • Hand XR
  • Head CT

This is a relatively easy task for a model to learn.

To Do:

  • Add generic inference and possibly evaluation scripts
  • Add a dicom dataset loader / class
  • Add a dicom --> hdf5 preprocessing torch.utils.data.DataLoader
  • add a hdf5 dataset class
  • Test on Windows

Have fun!

Shield: CC BY 4.0

This work is licensed under a Creative Commons Attribution 4.0 International License.

CC BY 4.0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages