Medical Imaging Deep Learning library to train and deploy 3D segmentation models on Azure Machine Learning
Перейти к файлу
Shruthi42 9fcc08f6cd
Run inference using checkpoints from registered models (#509)
2021-07-15 14:31:15 +00:00
.github/workflows Enable Bring-your-own-Lightning-model (#417) 2021-04-19 15:28:41 +00:00
.idea Bug fix for regression test (#496) 2021-06-21 14:39:09 +01:00
InnerEye Run inference using checkpoints from registered models (#509) 2021-07-15 14:31:15 +00:00
RegressionTestResults Update PL to 1.3.8 (#531) 2021-07-13 10:24:20 +01:00
TestSubmodule Switch more code to using Path (#305) 2020-11-02 19:49:13 +00:00
Tests Run inference using checkpoints from registered models (#509) 2021-07-15 14:31:15 +00:00
TestsOutsidePackage Update dicom-rt converter (#430) 2021-04-13 11:20:11 +02:00
azure-pipelines Run inference using checkpoints from registered models (#509) 2021-07-15 14:31:15 +00:00
docs Run inference using checkpoints from registered models (#509) 2021-07-15 14:31:15 +00:00
fastMRI@f2070aeb7a Enable Bring-your-own-Lightning-model (#417) 2021-04-19 15:28:41 +00:00
sphinx-docs renaming master -> main (#384) 2021-02-02 15:48:21 +00:00
.amlignore Reduce AML snapshot size by skipping test folders (#497) 2021-06-22 14:47:17 +01:00
.coveragerc Fix error messages in test coverage reporting (#394) 2021-02-10 14:29:20 +00:00
.editorconfig Add source code 2020-07-29 00:30:35 +05:30
.flake8 Fix timeouts when downloading multiple checkpoint files (#498) 2021-06-22 13:33:33 +00:00
.gitattributes Regression test coverage for AzureML runs (#492) 2021-06-17 20:37:57 +00:00
.gitconfig Add source code 2020-07-29 00:30:35 +05:30
.gitignore Added ability to run segmentation inference module in the test data without or partial ground truth files. (#465) 2021-07-05 16:22:13 +00:00
.gitmodules Enable Bring-your-own-Lightning-model (#417) 2021-04-19 15:28:41 +00:00
CHANGELOG.md Run inference using checkpoints from registered models (#509) 2021-07-15 14:31:15 +00:00
CODE_OF_CONDUCT.md Add source code 2020-07-29 00:30:35 +05:30
GeoPol.xml Add source code 2020-07-29 00:30:35 +05:30
LICENSE Add source code 2020-07-29 00:30:35 +05:30
README.md Update README.md (#511) 2021-07-14 17:18:50 +01:00
SECURITY.md Add source code 2020-07-29 00:30:35 +05:30
THIRDPARTYNOTICES.md Remove unnecessary notices in THIRDPARTYNOTICES.md 2020-11-03 15:37:43 +00:00
conftest.py Remove model configurations dependency on Tests. This was breaking inference. (#361) 2021-01-15 17:25:57 +00:00
environment.yml Update PL to 1.3.8 (#531) 2021-07-13 10:24:20 +01:00
mypy.ini Add source code 2020-07-29 00:30:35 +05:30
mypy_runner.py Add arguments in mypy_runner.py to specify a list of directories to run mypy on (#463) 2021-05-21 11:10:40 +01:00
pull_request_template.md Document how we do releases (#315) 2020-11-13 14:03:51 +00:00
pytest.ini Register all models after training, not only Segmentation models. (#455) 2021-05-12 15:03:35 +01:00
score.py Register all models after training, not only Segmentation models. (#455) 2021-05-12 15:03:35 +01:00
setup.py Add accuracy at threshold 0.5 to classification report (#450) 2021-05-04 10:09:35 +00:00

README.md

InnerEye-DeepLearning

Build Status

Overview

This is a deep learning toolbox to train models on medical images (or more generally, 3D images). It integrates seamlessly with cloud computing in Azure.

On the modelling side, this toolbox supports

  • Segmentation models
  • Classification and regression models
  • Sequence models
  • Adding cloud support to any PyTorch Lightning model, via a bring-your-own-model setup

Classification, regression, and sequence models can be built with only images as inputs, or a combination of images and non-imaging data as input. This supports typical use cases on medical data where measurements, biomarkers, or patient characteristics are often available in addition to images.

On the user side, this toolbox focusses on enabling machine learning teams to achieve more. It is cloud-first, and relies on Azure Machine Learning Services (AzureML) for execution, bookkeeping, and visualization. Taken together, this gives:

  • Traceability: AzureML keeps a full record of all experiments that were executed, including a snapshot of the code. Tags are added to the experiments automatically, that can later help filter and find old experiments.
  • Transparency: All team members have access to each other's experiments and results.
  • Reproducibility: Two model training runs using the same code and data will result in exactly the same metrics. All sources of randomness like multithreading are controlled for.
  • Cost reduction: Using AzureML, all compute (virtual machines, VMs) is requested at the time of starting the training job, and freed up at the end. Idle VMs will not incur costs. In addition, Azure low priority nodes can be used to further reduce costs (up to 80% cheaper).
  • Scale out: Large numbers of VMs can be requested easily to cope with a burst in jobs.

Despite the cloud focus, all training and model testing works just as well on local compute, which is important for model prototyping, debugging, and in cases where the cloud can't be used. In particular, if you already have GPU machines available, you will be able to utilize them with the InnerEye toolbox.

In addition, our toolbox supports:

  • Cross-validation using AzureML's built-in support, where the models for individual folds are trained in parallel. This is particularly important for the long-running training jobs often seen with medical images.
  • Hyperparameter tuning using Hyperdrive.
  • Building ensemble models.
  • Easy creation of new models via a configuration-based approach, and inheritance from an existing architecture.

Once training in AzureML is done, the models can be deployed from within AzureML or via Azure Stack Hub.

Getting started

We recommend using our toolbox with Linux or with the Windows Subsystem for Linux (WSL2). Much of the core functionality works fine on Windows, but PyTorch's full feature set is only available on Linux. Read more about WSL here.

Clone the repository into a subfolder of the current directory:

git clone --recursive https://github.com/microsoft/InnerEye-DeepLearning
cd InnerEye-DeepLearning
git lfs install
git lfs pull

After that, you need to set up your Python environment:

  • Install conda or miniconda for your operating system.
  • Create a Conda environment from the environment.yml file in the repository root, and activate it:
conda env create --file environment.yml
conda activate InnerEye
  • If environment creation fails with odd error messages on a Windows machine, please continue here.

Now try to run the HelloWorld segmentation model - that's a very simple model that will train for 2 epochs on any machine, no GPU required. You need to set the PYTHONPATH environment variable to point to the repository root first. Assuming that your current directory is the repository root folder, on Linux bash that is:

export PYTHONPATH=`pwd`
python InnerEye/ML/runner.py --model=HelloWorld

(Note the "backtick" around the pwd command, this is not a standard single quote!)

On Windows:

set PYTHONPATH=%cd%
python InnerEye/ML/runner.py --model=HelloWorld

If that works: Congratulations! You have successfully built your first model using the InnerEye toolbox.

If it fails, please check the troubleshooting page on the Wiki.

Further detailed instructions, including setup in Azure, are here:

  1. Setting up your environment
  2. Training a Hello World segmentation model
  3. Setting up Azure Machine Learning
  4. Creating a dataset
  5. Building models in Azure ML
  6. Sample Segmentation and Classification tasks
  7. Debugging and monitoring models
  8. Model diagnostics
  9. Move a model to a different workspace
  10. Working with FastMRI models

Deployment

We offer a companion set of open-sourced tools that help to integrate trained CT segmentation models with clinical software systems:

  • The InnerEye-Gateway is a Windows service running in a DICOM network, that can route anonymized DICOM images to an inference service.
  • The InnerEye-Inference component offers a REST API that integrates with the InnnEye-Gateway, to run inference on InnerEye-DeepLearning models.

Details can be found here.

docs/deployment.png

More information

  1. Project InnerEye
  2. Releases
  3. Changelog
  4. Testing
  5. How to do pull requests
  6. Contributing

Licensing

MIT License

You are responsible for the performance, the necessary testing, and if needed any regulatory clearance for any of the models produced by this toolbox.

Contact

If you have any feature requests, or find issues in the code, please create an issue on GitHub.

Please send an email to InnerEyeInfo@microsoft.com if you would like further information about this project.

Publications

Oktay O., Nanavati J., Schwaighofer A., Carter D., Bristow M., Tanno R., Jena R., Barnett G., Noble D., Rimmer Y., Glocker B., OHara K., Bishop C., Alvarez-Valle J., Nori A.: Evaluation of Deep Learning to Augment Image-Guided Radiotherapy for Head and Neck and Prostate Cancers. JAMA Netw Open. 2020;3(11):e2027426. doi:10.1001/jamanetworkopen.2020.27426

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Credits

This toolbox is maintained by the Microsoft InnerEye team, and has received valuable contributions from a number of people outside our team. We would like to thank in particular our interns, Yao Quin, Zoe Landgraf, Padmaja Jonnalagedda, Mathias Perslev, as well as the AI Residents Patricia Gillespie and Guilherme Ilunga.