-
Notifications
You must be signed in to change notification settings - Fork 31
BraTS integration with MLCube [WIP] #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
davidjurado
wants to merge
29
commits into
mlcommons:master
Choose a base branch
from
davidjurado:feature/brats
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
49a5920
Add BraTS integration with MLCube
davidjurado 40d335c
Fix README
davidjurado 1e014cb
Refactor folder project to make it more understandable
davidjurado 3a1d28c
Add project workflow diagram
davidjurado 3a8bae6
Fix typos
davidjurado b9d2b2d
Add missing command
davidjurado 6c9536c
Refactor project to match MedPerf specifications
davidjurado 597fc44
Refactor project and add metrics MLCube
davidjurado bbbf85a
Add comments to metrics file
davidjurado 02fe758
Fix readme
davidjurado 6cfe2dc
Add preprocess MLCube
davidjurado 8521cf0
Update preprocessing MLCube task
davidjurado 37730f4
Update readme
davidjurado aa4dfda
Fix preprocessing mlcube.yaml file
davidjurado 8376c35
Fix preprocessing sanity check
davidjurado 5de23b9
Add missing task for preprocessing MLCube
davidjurado bce60ed
Add model MLCube
davidjurado f47949b
Fix metrics MLCube
davidjurado 7d13bc5
Fix model MLCube
davidjurado 9ecfc19
Fix model paths
davidjurado 0434321
Fix preprocessing logic
davidjurado 10bbfe6
Fix model logic
davidjurado cc0fc40
Fix model files
davidjurado ab20d9b
Add dataset in tar format
davidjurado 128c691
Add preprocessing output as model input
davidjurado 7fc2387
Update Readme
davidjurado 4b840fe
Fix Docker image convertion to Singularity
davidjurado 81f7aff
Merge branch 'feature/brats' of github.com:davidjurado/mlcube_example…
davidjurado 45a44d9
Add Docker to singularity instructions
davidjurado File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # author info | ||
| AUTHOR_NAME = "Chuck Norris" | ||
| AUTHOR_EMAIL = "[email protected]" | ||
| # put your app name here | ||
| APPLICATION_NAME = "AMAZING APPLICATION" | ||
| # specify version here, if possible use semantic versioning | ||
| APPLICATION_VERSION = "0.0.1" | ||
|
|
||
| INPUT_FOLDER ="workspace/data/" | ||
| OUTPUT_FOLDER ="workspace/data/results/" | ||
|
|
||
| INPUT_FOLDER_DOCKER="/app/data/" | ||
| OUTPUT_FOLDER_DOCKER ="/app/data/results/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| __pycache__/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # for a CPU app use this Dockerfile, delete the Dockerfile_CUDA then. | ||
| FROM python:3.8-buster | ||
|
|
||
| # fill in your info here | ||
| LABEL author="[email protected]" | ||
| LABEL application="your application name" | ||
| LABEL maintainer="[email protected]" | ||
| LABEL version="0.0.1" | ||
| LABEL status="beta" | ||
|
|
||
| # basic | ||
| RUN apt-get -y update && apt -y full-upgrade && apt-get -y install apt-utils wget git tar build-essential curl nano | ||
|
|
||
| # install all python requirements | ||
| WORKDIR /app | ||
| COPY ./requirements.txt ./requirements.txt | ||
| RUN pip3 install -r requirements.txt | ||
|
|
||
| # copy all files | ||
| COPY ./ ./ | ||
|
|
||
| ENTRYPOINT [ "python3","-u", "run.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # for a GPU app use this Dockerfile, delete the Dockerfile_CPU then. | ||
| FROM nvidia/cuda:10.1-cudnn7-runtime-ubuntu18.04 | ||
|
|
||
| # fill in your info here | ||
| LABEL author="[email protected]" | ||
| LABEL application="your application name" | ||
| LABEL maintainer="[email protected]" | ||
| # specify version here, if possible use semantic versioning | ||
| LABEL version="0.0.1" | ||
| LABEL status="beta" | ||
|
|
||
| # basic | ||
| RUN apt-get -y update && apt -y full-upgrade && apt-get -y install apt-utils wget git tar build-essential curl nano | ||
|
|
||
| # install python 3.6.9 | ||
| RUN apt-get update -y && apt-get install -y python3-pip python3-dev | ||
|
|
||
| # install all python requirements | ||
| WORKDIR /app | ||
| COPY ./requirements.txt ./requirements.txt | ||
| RUN pip3 install -r requirements.txt | ||
|
|
||
| # copy all files | ||
| COPY ./ ./ | ||
| RUN pip3 install -U python-dotenv | ||
|
|
||
| ENTRYPOINT [ "python3","-u", "run.py"] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # BraTS Challenge 2020 - MLCube integration | ||
|
|
||
| Original implementation: ["BraTS Instructions Repo"](https://github.com/BraTS/Instructions) | ||
|
|
||
| ## Dataset | ||
|
|
||
| Please refer to the [BraTS challenge page](http://braintumorsegmentation.org/) and follow the instructions in the data section. | ||
|
|
||
| ## Project setup | ||
|
|
||
| ```bash | ||
| # Create Python environment and install MLCube Docker runner | ||
| virtualenv -p python3 ./env && source ./env/bin/activate && pip install mlcube-docker | ||
|
|
||
| # Fetch the boston housing example from GitHub | ||
| git clone https://github.com/mlcommons/mlcube_examples && cd ./mlcube_examples | ||
| git fetch origin pull/39/head:feature/brats && git checkout feature/brats | ||
| cd ./brats | ||
| ``` | ||
|
|
||
| ## Tasks execution | ||
|
|
||
| ```bash | ||
| # Run implementation with CPU support. | ||
| mlcube run --mlcube=mlcube_cpu.yaml --task=run | ||
|
|
||
| # Run implementation with GPU support. | ||
| mlcube run --mlcube=mlcube_gpu.yaml --task=run | ||
| ``` | ||
|
|
||
| We are targeting pull-type installation, so MLCube images should be available on Docker Hub. If not, try this: | ||
|
|
||
| ```Bash | ||
| mlcube run ... -Pdocker.build_strategy=always | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: MLCommons Brats | ||
| description: MLCommons Brats integration | ||
| authors: | ||
| - {name: "MLCommons Best Practices Working Group"} | ||
|
|
||
| platform: | ||
| accelerator_count: 0 | ||
|
|
||
| docker: | ||
| # Image name. | ||
| image: mlcommons/brats_cpu:0.0.1 | ||
| # Docker build context relative to $MLCUBE_ROOT. Default is `build`. | ||
| build_context: "." | ||
| # Docker file name within docker build context, default is `Dockerfile`. | ||
| build_file: "Dockerfile_CPU" | ||
|
|
||
| tasks: | ||
| run: | ||
| # Run implementation | ||
| parameters: | ||
| inputs: {data_dir: data/} | ||
| outputs: {results_dir: data/results/} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: MLCommons Brats | ||
| description: MLCommons Brats integration | ||
| authors: | ||
| - {name: "MLCommons Best Practices Working Group"} | ||
|
|
||
| platform: | ||
| accelerator_count: 0 | ||
|
|
||
| docker: | ||
| # Image name. | ||
| image: mlcommons/brats_gpu:0.0.1 | ||
| # Docker build context relative to $MLCUBE_ROOT. Default is `build`. | ||
| build_context: "." | ||
| # Docker file name within docker build context, default is `Dockerfile`. | ||
| build_file: "Dockerfile_CUDA" | ||
|
|
||
| tasks: | ||
| run: | ||
| # Run implementation | ||
| parameters: | ||
| inputs: {data_dir: data/} | ||
| outputs: {results_dir: data/results/} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| python-dotenv==0.12.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """Load code""" | ||
| import argparse | ||
| from src.amazing_logic import run_code | ||
|
|
||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument( | ||
| "--data_dir", | ||
| type=str, | ||
| default=None, | ||
| help="Path to dataset.", | ||
| ) | ||
| parser.add_argument( | ||
| "--results_dir", | ||
| type=str, | ||
| default=None, | ||
| help="Path to output folder.", | ||
| ) | ||
| args, _unkown = parser.parse_known_args() | ||
|
|
||
| # execute | ||
| run_code(args) |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| """Logic file""" | ||
| import os | ||
| from shutil import copyfile | ||
| from dotenv import dotenv_values | ||
| from src.utils.utilities import helper | ||
|
|
||
| config = dotenv_values(".env") | ||
| APPLICATION_NAME = config["APPLICATION_NAME"] | ||
| APPLICATION_VERSION = config["APPLICATION_VERSION"] | ||
| INPUT_FOLDER = config["INPUT_FOLDER"] | ||
| OUTPUT_FOLDER = config["OUTPUT_FOLDER"] | ||
|
|
||
|
|
||
| def logic_wrapper(args): | ||
| """Edit your logic here""" | ||
| if args.data_dir is not None: | ||
| INPUT_FOLDER = args.data_dir | ||
| input_file = os.path.normpath(INPUT_FOLDER + "/something_t1.nii.gz") | ||
| # ... do the same for t1c, flair and t2 here | ||
| if args.results_dir is not None: | ||
| OUTPUT_FOLDER = args.results_dir | ||
| output_file = os.path.normpath(OUTPUT_FOLDER + "/something_seg.nii.gz") | ||
|
|
||
| # copy paste your amazing logic here | ||
| print("wrapper: I can feel the magic happening..it feels like a little sun rising inside me!") | ||
|
|
||
| # example logic | ||
| copyfile(input_file, output_file) | ||
| helper() | ||
|
|
||
|
|
||
| def run_code(args): | ||
| """Main function""" | ||
| print("*** code execution started:", | ||
| APPLICATION_NAME, "version:", APPLICATION_VERSION, "! ***") | ||
| logic_wrapper(args) | ||
| print("*** code execution finished:", | ||
| APPLICATION_NAME, "version:", APPLICATION_VERSION, "! ***") | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| """utility functions here""" | ||
| def helper(): | ||
| """helper function""" | ||
| print("helper: I am so useful it hurts.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| output.nii.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| * | ||
| !.gitignore | ||
| !.dockerignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| I am a standardized compressed nifti file! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| exam_id,age,resection_status | ||
| something,NA,NA | ||
|
|
||
| First column: exam name, string for the exam name | ||
| Second Column: Age as a float or NA for missing | ||
| Third Column: resection status as NA for missing, GTR/STR as a string | ||
|
|
||
| ATTENTION: note the slightly changed column names in comparison to what you received for testing | ||
|
|
||
| Example for a case without missing data: | ||
|
|
||
| exam_id,age,resection_status | ||
| BraTS20_Testing_015,51.449,GTR | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| I am a standardized compressed nifti file! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| I am a standardized compressed nifti file! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| I am a standardized compressed nifti file! |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read INPUT_FOLDER and OUTPUT_FOLDER from --data_dir and --results_dir only; and taken them out of the .env file