HI-ML toolbox for deep learning for medical imaging and Azure integration
Перейти к файлу
Anton Schwaighofer 788b1b6d62 doc 2024-06-24 11:40:56 +01:00
.devcontainer Remove trailing whitespaces (#346) 2022-05-18 08:28:52 +00:00
.github MNT: Upgrade to password-free authentication (#925) 2024-04-12 13:26:41 +01:00
azure-pipelines Add code analysis steps required for public release to our pipeline (#65) 2021-08-13 14:38:35 +01:00
docs ENH: Upgrade to Python 3.9 and package update (#910) 2023-11-09 13:17:38 +00:00
hi-ml ENH: Upgrade to Python 3.9 and package update (#910) 2023-11-09 13:17:38 +00:00
hi-ml-azure doc 2024-06-24 11:40:56 +01:00
hi-ml-cpath ENH: Remove mount context imports (#919) 2024-02-29 16:13:27 +00:00
hi-ml-multimodal MNT: Bump `hi-ml-multimodal` version (#929) 2024-05-13 13:03:50 +01:00
new_project_template ENH: Upgrade to Python 3.9 and package update (#910) 2023-11-09 13:17:38 +00:00
.amlignore ENH: Rename histopathology folder to match overall naming scheme (#512) 2022-07-18 13:40:47 +01:00
.amltignore ENH: Improve Amulet support and documentation (#612) 2022-09-26 15:29:18 +00:00
.codecov.yml TEST: Update CI to compute and upload coverage for hi-ml-multimodal (#685) 2022-11-29 21:31:37 +00:00
.coveragerc Adding cross-validation to the hi-ml runner (#198) 2022-03-07 12:21:09 +00:00
.git-blame-ignore-revs STY: Ignore styling in git blame 2023-03-23 15:43:37 +00:00
.gitignore ENH: Better commandline parsing of Enums (#861) 2023-04-03 10:23:41 +01:00
.isort.cfg ENH: Enable LoadROId with Openslide (#672) 2022-11-22 22:51:34 +00:00
.pre-commit-config.yaml ENH: Autoupdate hooks [pre-commit.ci] (#864) 2023-04-04 17:28:34 +01:00
CHANGELOG.md BUG: Correct pythonpath separator character in VS code settings file (#267) 2022-03-25 15:07:01 +00:00
CODE_OF_CONDUCT.md CODE_OF_CONDUCT.md committed 2021-07-01 12:31:50 -07:00
LICENSE LICENSE updated to template 2021-07-01 12:31:50 -07:00
Makefile FIX: Fix target names in Makefile (#865) 2023-04-06 13:00:24 +01:00
README.md 💄 Add black styling and configuration 2023-03-23 14:32:03 +00:00
SECURITY.md Remove trailing whitespaces (#346) 2022-05-18 08:28:52 +00:00
build_requirements.txt ENH: Add code to create montages from WSI (#787) 2023-02-09 19:50:07 +00:00
create_and_lock_environment.sh ENH: Use a locked environment hi-ml folder (#598) 2022-09-09 17:01:50 +01:00
create_config.sh ENH: Add github workflow for smoke testing DeepSMILEPandaSlidesBenchmark (#506) 2022-07-19 17:29:28 +01:00
hello_world.yml ENH: Improve Amulet support and documentation (#612) 2022-09-26 15:29:18 +00:00
himl-projects.code-workspace ENH: Rename histopathology folder to match overall naming scheme (#512) 2022-07-18 13:40:47 +01:00
hubconf.py ♻️ Style and fix mypy 2023-03-23 15:06:19 +00:00
pyproject.toml 💄 Add black styling and configuration 2023-03-23 14:32:03 +00:00
pyrightconfig.json ENH: Improve Amulet support and documentation (#612) 2022-09-26 15:29:18 +00:00
readthedocs_requirements.txt ENH: Rename "multimodal" to "hi-ml-multimodal" (#467) 2022-06-28 16:20:47 +01:00
runtime.txt FIX: Fix notebook not working on Binder (#852) 2023-03-23 17:47:48 +00:00
test_requirements.txt ENH: Upgrade to Python 3.9 and package update (#910) 2023-11-09 13:17:38 +00:00

README.md

Microsoft Health Intelligence Machine Learning Toolbox

Codecov coverage Code style: black

Overview

This toolbox aims at providing low-level and high-level building blocks for Machine Learning / AI researchers and practitioners. It helps to simplify and streamline work on deep learning models for healthcare and life sciences, by providing tested components (data loaders, pre-processing), deep learning models, and cloud integration tools.

This repository consists of two Python packages, as well as project-specific codebases:

  • PyPi package hi-ml-azure - providing helper functions for running in AzureML.
  • PyPi package hi-ml - providing ML components.
  • hi-ml-cpath: Models and workflows for working with histopathology images

Getting started

For the full toolbox (this will also install hi-ml-azure):

  • Install from pypi via pip, by running pip install hi-ml

For just the AzureML helper functions:

  • Install from pypi via pip, by running pip install hi-ml-azure

For the histopathology workflows, please follow the instructions here.

If you would like to contribute to the code, please check the developer guide.

Documentation

The detailed package documentation, with examples and API reference, is on readthedocs.

Quick start: Using the Azure layer

Use case: you have a Python script that does something - that could be training a model, or pre-processing some data. The hi-ml-azure package can help easily run that on Azure Machine Learning (AML) services.

Here is an example script that reads images from a folder, resizes and saves them to an output folder:

from pathlib import Path
if __name__ == '__main__':
    input_folder = Path("/tmp/my_dataset")
    output_folder = Path("/tmp/my_output")
    for file in input_folder.glob("*.jpg"):
        contents = read_image(file)
        resized = contents.resize(0.5)
        write_image(output_folder / file.name)

Doing that at scale can take a long time. We'd like to run that script in AzureML, consume the data from a folder in blob storage, and write the results back to blob storage.

With the hi-ml-azure package, you can turn that script into one that runs on the cloud by adding one function call:

from pathlib import Path
from health_azure import submit_to_azure_if_needed
if __name__ == '__main__':
    current_file = Path(__file__)
    run_info = submit_to_azure_if_needed(compute_cluster_name="preprocess-ds12",
                                         input_datasets=["images123"],
                                         # Omit this line if you don't create an output dataset (for example, in
                                         # model training scripts)
                                         output_datasets=["images123_resized"],
                                         default_datastore="my_datastore")
    # When running in AzureML, run_info.input_datasets and run_info.output_datasets will be populated,
    # and point to the data coming from blob storage. For runs outside AML, the paths will be None.
    # Replace the None with a meaningful path, so that we can still run the script easily outside AML.
    input_dataset = run_info.input_datasets[0] or Path("/tmp/my_dataset")
    output_dataset = run_info.output_datasets[0] or Path("/tmp/my_output")
    files_processed = []
    for file in input_dataset.glob("*.jpg"):
        contents = read_image(file)
        resized = contents.resize(0.5)
        write_image(output_dataset / file.name)
        files_processed.append(file.name)
    # Any other files that you would not consider an "output dataset", like metrics, etc, should be written to
    # a folder "./outputs". Any files written into that folder will later be visible in the AzureML UI.
    # run_info.output_folder already points to the correct folder.
    stats_file = run_info.output_folder / "processed_files.txt"
    stats_file.write_text("\n".join(files_processed))

Once these changes are in place, you can submit the script to AzureML by supplying an additional --azureml flag on the commandline, like python myscript.py --azureml.

That's it!

For details, please refer to the onboarding page.

For more examples, please see examples.md.

Issues

If you've found a bug in the code, please check the issues page. If no existing issue exists, please open a new one. Be sure to include

  • A descriptive title
  • Expected behaviour (including a code sample if possible)
  • Actual behavior

Contributing

We welcome all contributions that help us achieve our aim of speeding up ML/AI research in health and life sciences. Examples of contributions are

  • Data loaders for specific health & life sciences data
  • Network architectures and components for deep learning models
  • Tools to analyze and/or visualize data
  • ...

Please check the detailed page about contributions.

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.

Contribution Licensing

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.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.