Skip to content

[WIP] Adding Stain Normalization Transform for Pathology #1912

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

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
63ad63c
Update CuCIM (#1909)
bhashemian Mar 31, 2021
e761433
Update pathology unittests (#1910)
bhashemian Mar 31, 2021
8337cd2
added stain norm transform
Mar 31, 2021
71ce959
Update prob map handler (#1911)
bhashemian Apr 1, 2021
40afac8
Implement dice_focal loss (#1914)
yiheng-wang-nv Apr 1, 2021
5113396
followup of #1878 (#1913)
wyli Apr 1, 2021
7552279
1868-fix-potential-inf-in-lncc-loss (#1915)
kate-sann5100 Apr 1, 2021
47a3069
1919 - test pt 2103 (#1920)
wyli Apr 2, 2021
89447c4
fixes typos (#1924)
wyli Apr 2, 2021
26749ff
1900 Add support to save patch data into NIfTI or PNG files (#1922)
Nic-Ma Apr 3, 2021
7300b92
Revert "1919 - test pt 2103 (#1920)" (#1925)
wyli Apr 3, 2021
11e6a81
skip warp tests before torch 18 (#1927)
wyli Apr 3, 2021
d5afef3
update docstrings (#1931)
wyli Apr 3, 2021
7a2ac8a
update get_package_version (#1930)
wyli Apr 3, 2021
f602cdc
1904 Add early stop handler (#1921)
Nic-Ma Apr 3, 2021
b67aed7
1900 Change to save `patch_index` in the meta_dict (#1933)
Nic-Ma Apr 3, 2021
b5dbcbe
enhance min/exact version check (#1937)
wyli Apr 4, 2021
18b50a5
Enabled partial checkpoint loading (#1936)
danieltudosiu Apr 4, 2021
4c2894d
fixes issue of typing with py3.6 (#1942)
wyli Apr 5, 2021
fc547d3
Make ProbNMS a Transform (#1941)
bhashemian Apr 5, 2021
29d3ae5
fixes ThreadDataLoader (#1945)
wyli Apr 5, 2021
a5c631d
fixes itk dep. version (#1944)
wyli Apr 5, 2021
ec0b5ad
Garbage Collector Handler (#1940)
bhashemian Apr 5, 2021
a5ed4a4
style and api changes
Apr 5, 2021
5e7be9b
1939 Add strict_shape option in CheckpointLoader (#1946)
Nic-Ma Apr 5, 2021
b420c79
1947 Enhance load decathlon datalist API (#1948)
Nic-Ma Apr 5, 2021
aa251ea
Add progress bar to LesionFROC (#1951)
bhashemian Apr 5, 2021
d3b5eec
pipeline for releasing the docker images (#1953)
wyli Apr 6, 2021
4aad0cf
remove unused RandomizableTransform (#1952)
wyli Apr 6, 2021
4456604
1956 - docker image building pipelines (#1957)
wyli Apr 7, 2021
1c4dcd9
1955 style issue (#1958)
wyli Apr 7, 2021
6e39205
Update garbage collection assertion (#1959)
bhashemian Apr 7, 2021
2fdee25
Working ParameterScheduler (#1949)
danieltudosiu Apr 7, 2021
4803f9d
[DLMED] remove warning (#1962)
Nic-Ma Apr 7, 2021
08dfbeb
1916 Add support for custom events in workflows (#1961)
Nic-Ma Apr 7, 2021
b1703b2
added cupy requirement
Apr 7, 2021
f965d49
1965 - register_backward_hook (#1966)
wyli Apr 7, 2021
06c9720
1968 Enhance meta data doc-string in SegmentationSaver (#1969)
Nic-Ma Apr 8, 2021
43acc44
made cupy an optional import
nsrivathsa Apr 8, 2021
c18f20c
minor changes per comments
nsrivathsa Apr 9, 2021
5bd8a83
Adding EfficientNetsB0-B7 support (#1938)
masadcv Apr 9, 2021
b5b89c6
1866 Add TransformInverter handler (#1970)
Nic-Ma Apr 9, 2021
66c78ab
1889 - changelog for v0.5.0 (#1923)
wyli Apr 9, 2021
4487a53
1977 Support different inverse interpolation mode (#1978)
Nic-Ma Apr 9, 2021
997e6a1
Update technical highlights for v0.5 (#1981)
Nic-Ma Apr 9, 2021
cb58c96
1973 - docstring update convs example (#1980)
wyli Apr 10, 2021
9b3dd3f
test runner (#1986)
kate-sann5100 Apr 10, 2021
8bbc607
1987 Add support for a list of Tensor in metrics handlers (#1988)
Nic-Ma Apr 10, 2021
daf6730
add timeout (#1989)
wyli Apr 11, 2021
f39bed4
fixes ci error handling (#1990)
wyli Apr 11, 2021
b71b607
1889 update preview version number (#1991)
wyli Apr 12, 2021
875bcab
minor formatting change
nsrivathsa Apr 12, 2021
f319c27
fix comprehension error (#1995)
rijobro Apr 12, 2021
be632aa
Import cupy for type checking
bhashemian Apr 12, 2021
060421b
added unit tests
nsrivathsa Apr 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ docs/
.coverage/
coverage.xml
.readthedocs.yml
*.md
*.toml

!README.md
Expand Down
29 changes: 15 additions & 14 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: crons
on:
schedule:
- cron: "0 2 * * *" # at 02:00 UTC
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
cron-gpu:
Expand Down Expand Up @@ -40,17 +42,14 @@ jobs:
nvidia-smi
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
echo $CUDA_VISIBLE_DEVICES
stop_time=$((LAUNCH_DELAY + $(date +%s)))
while [ $(date +%s) -lt $stop_time ]; do
python -c 'import torch; torch.rand(5, 3, device=torch.device("cuda:0"))';
done
trap 'if pgrep python; then pkill python; fi;' ERR
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
python -c 'import torch; print(torch.rand(5, 3, device=torch.device("cuda:0")))'
BUILD_MONAI=1 ./runtests.sh --coverage --unittests # unit tests with coverage report
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
echo $CUDA_VISIBLE_DEVICES
BUILD_MONAI=1 ./runtests.sh --coverage --net # integration tests with coverage report
coverage xml
if pgrep python; then pkill python; fi
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
Expand Down Expand Up @@ -83,17 +82,14 @@ jobs:
nvidia-smi
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
echo $CUDA_VISIBLE_DEVICES
stop_time=$((LAUNCH_DELAY + $(date +%s)))
while [ $(date +%s) -lt $stop_time ]; do
python -c 'import torch; torch.rand(5, 3, device=torch.device("cuda:0"))';
done
trap 'if pgrep python; then pkill python; fi;' ERR
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
python -c 'import torch; print(torch.rand(5, 3, device=torch.device("cuda:0")))'
BUILD_MONAI=1 ./runtests.sh --coverage --unittests # unit tests with coverage report
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
echo $CUDA_VISIBLE_DEVICES
BUILD_MONAI=1 ./runtests.sh --coverage --net # integration tests with coverage report
coverage xml
if pgrep python; then pkill python; fi
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
Expand All @@ -115,14 +111,15 @@ jobs:
nvidia-smi
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
echo $CUDA_VISIBLE_DEVICES
trap 'if pgrep python; then pkill python; fi;' ERR
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
python -c 'import torch; print(torch.rand(5,3, device=torch.device("cuda:0")))'
ngc --version
BUILD_MONAI=1 ./runtests.sh --coverage --pytype --unittests # unit tests with pytype checks, coverage report
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
echo $CUDA_VISIBLE_DEVICES
BUILD_MONAI=1 ./runtests.sh --coverage --net # integration tests with coverage report
coverage xml
if pgrep python; then pkill python; fi
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
Expand Down Expand Up @@ -156,8 +153,12 @@ jobs:
cd tutorials
python -m pip install -r requirements.txt
- name: Run tutorial notebooks
timeout-minutes: 150
run: |
export CUDA_VISIBLE_DEVICES=${{ steps.monai-install.outputs.devices }}
echo $CUDA_VISIBLE_DEVICES
trap 'if pgrep python; then pkill python; fi;' ERR
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
cd /opt/tutorials
$(pwd)/runner.sh
if pgrep python; then pkill python; fi
123 changes: 123 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: docker
# versioning: compute a static version file
# local_docker: use the version file to build docker images
# docker_test_latest: test the latest internal docker image (has flake)
# docker_test_dockerhub: test the latest dockerhub release (no flake)
on:
# master only docker deployment and quick tests
push:
branches:
- master
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
versioning:
# compute versioning file from python setup.py
# upload as artifact
# (also used in release.yml)
if: github.repository == 'Project-MONAI/MONAI'
container:
image: localhost:5000/local_monai:latest
runs-on: [self-hosted, linux, x64, build_only]
steps:
- uses: actions/checkout@v2
# full history so that we can git describe
with:
ref: master
fetch-depth: 0
- shell: bash
run: |
git describe
python setup.py build
cat build/lib/monai/_version.py
- name: Upload version
uses: actions/upload-artifact@v2
with:
name: _version.py
path: build/lib/monai/_version.py
- name: Clean up directory
shell: bash
run: |
ls -al
rm -rf {*,.[^.]*}

local_docker:
# builds two versions: local_monai:latest and local_monai:dockerhub
# latest: used for local tests
# dockerhub: release, no flake package
if: github.repository == 'Project-MONAI/MONAI'
needs: versioning
runs-on: [self-hosted, linux, x64, build_only]
steps:
- uses: actions/checkout@v2
with:
ref: master
- name: Download version
uses: actions/download-artifact@v2
with:
name: _version.py
- name: docker_build
shell: bash
run: |
# get tag info for versioning
cat _version.py
mv _version.py monai/
# build and run original docker image for local registry
docker build -t localhost:5000/local_monai:latest -f Dockerfile .
docker push localhost:5000/local_monai:latest
# build once more w/ tag "latest": remove flake package as it is not needed on hub.docker.com
sed -i '/flake/d' requirements-dev.txt
docker build -t projectmonai/monai:latest -f Dockerfile .
# also push as tag "dockerhub" to local registry
docker image tag projectmonai/monai:latest localhost:5000/local_monai:dockerhub
docker push localhost:5000/local_monai:dockerhub
# distribute as always w/ tag "latest" to hub.docker.com
echo "${{ secrets.DOCKER_PW }}" | docker login -u projectmonai --password-stdin
docker push projectmonai/monai:latest
docker logout
docker image prune -f

docker_test_latest:
if: github.repository == 'Project-MONAI/MONAI'
needs: local_docker
container:
image: localhost:5000/local_monai:latest
runs-on: [self-hosted, linux, x64, common]
steps:
- name: Import
run: |
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
echo $CUDA_VISIBLE_DEVICES
trap 'if pgrep python; then pkill python; fi;' ERR
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
python -c 'import monai; monai.config.print_config()'
cd /opt/monai
ls -al
ngc --version
python -m tests.min_tests
if pgrep python; then pkill python; fi
env:
QUICKTEST: True

docker_test_dockerhub:
if: github.repository == 'Project-MONAI/MONAI'
needs: local_docker
container:
image: localhost:5000/local_monai:dockerhub
runs-on: [self-hosted, linux, x64, common]
steps:
- name: Import
run: |
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
echo $CUDA_VISIBLE_DEVICES
trap 'if pgrep python; then pkill python; fi;' ERR
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
python -c 'import monai; monai.config.print_config()'
cd /opt/monai
ls -al
ngc --version
python -m tests.min_tests
if pgrep python; then pkill python; fi
env:
QUICKTEST: True
7 changes: 6 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ jobs:
nvidia-smi
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
echo $CUDA_VISIBLE_DEVICES
trap 'if pgrep python; then pkill python; fi;' ERR
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
python -c 'import torch; print(torch.rand(5,3, device=torch.device("cuda:0")))'
BUILD_MONAI=1 ./runtests.sh --unittests --net
BUILD_MONAI=1 ./runtests.sh --net
BUILD_MONAI=1 ./runtests.sh --unittests
if pgrep python; then pkill python; fi
shell: bash
- name: Add reaction
uses: peter-evans/create-or-update-comment@v1
with:
Expand Down
60 changes: 56 additions & 4 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
# Git hub actions have 2 cores, so parallize pytype
$(pwd)/runtests.sh --codeformat -j 2

quick-py3: # full dependencies installed
quick-py3: # full dependencies installed tests for different OS
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
env:
QUICKTEST: True

min-dep-py3: # min dependencies installed
min-dep-os: # min dependencies installed tests for different OS
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -154,6 +154,51 @@ jobs:
env:
QUICKTEST: True

min-dep-py3: # min dependencies installed tests for different python
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7]
timeout-minutes: 40
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Prepare pip wheel
run: |
which python
python -m pip install --user --upgrade pip setuptools wheel
- name: cache weekly timestamp
id: pip-cache
run: |
echo "::set-output name=datew::$(date '+%Y-%V')"
echo "::set-output name=dir::$(pip cache dir)"
shell: bash
- name: cache for pip
uses: actions/cache@v2
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }}
- name: Install the dependencies
run: |
# min. requirements
python -m pip install torch==1.8.1
python -m pip install -r requirements-min.txt
python -m pip list
BUILD_MONAI=0 python setup.py develop # no compile of extensions
shell: bash
- name: Run quick tests (CPU ${{ runner.os }})
run: |
python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
python -c "import monai; monai.config.print_config()"
python -m tests.min_tests
env:
QUICKTEST: True

GPU-quick-py3: # GPU with full dependencies
if: github.repository == 'Project-MONAI/MONAI'
strategy:
Expand Down Expand Up @@ -236,21 +281,28 @@ jobs:
python -m pip install --upgrade pip wheel
python -m pip install ${{ matrix.pytorch }}
python -m pip install -r requirements-dev.txt
python -m pip list
- name: Run quick tests (GPU)
run: |
python -m pip list
nvidia-smi
export LAUNCH_DELAY=$(python -c "import numpy; print(numpy.random.randint(30) * 5)")
echo "Sleep $LAUNCH_DELAY"
sleep $LAUNCH_DELAY
export CUDA_VISIBLE_DEVICES=$(coverage run -m tests.utils)
echo $CUDA_VISIBLE_DEVICES
trap 'if pgrep python; then pkill python; fi;' ERR
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
python -c 'import torch; print(torch.rand(5, 3, device=torch.device("cuda:0")))'
python -c "import monai; monai.config.print_config()"
BUILD_MONAI=1 ./runtests.sh --quick --unittests
if [ ${{ matrix.environment }} == "PT18+CUDA112" ]; then
if [ ${{ matrix.environment }} = "PT18+CUDA112" ]; then
# test the clang-format tool downloading once
coverage run -m tests.clang_format_utils
fi
coverage xml
if pgrep python; then pkill python; fi
shell: bash
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
Expand Down
Loading