diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index d9ffdb7f5e..e568ba9e15 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -53,6 +53,38 @@ jobs: fail_ci_if_error: false file: ./coverage.xml + cron-pt-image: + if: github.repository == 'Project-MONAI/MONAI' + container: + image: nvcr.io/nvidia/pytorch:20.12-py3 # testing with the latest pytorch base image + options: "--gpus all" + runs-on: [self-hosted, linux, x64, common] + steps: + - uses: actions/checkout@v2 + - name: Install the dependencies + run: | + which python + python -m pip install --upgrade pip wheel + python -m pip install -r requirements-dev.txt + python -m pip list + - name: Run tests report coverage + run: | + export LAUNCH_DELAY=$[ $RANDOM % 16 * 60 ] + echo "Sleep $LAUNCH_DELAY" + sleep $LAUNCH_DELAY + nvidia-smi + export CUDA_VISIBLE_DEVICES=$(python -m tests.utils) + echo $CUDA_VISIBLE_DEVICES + 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 + coverage xml + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: false + file: ./coverage.xml + cron-docker: if: github.repository == 'Project-MONAI/MONAI' container: @@ -61,7 +93,8 @@ jobs: runs-on: [self-hosted, linux, x64, common] steps: - name: Run tests report coverage - # The docker image process has done the compilation. BUILD_MONAI=1 may not be necessary. + # The docker image process has done the compilation. + # BUILD_MONAI=1 is necessary for triggering the USE_COMPILED flag. run: | cd /opt/monai nvidia-smi diff --git a/Dockerfile b/Dockerfile index a600f9de84..47976b97b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:20.10-py3 +ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:20.12-py3 FROM ${PYTORCH_IMAGE} @@ -21,7 +21,8 @@ WORKDIR /opt/monai COPY requirements.txt requirements-min.txt requirements-dev.txt /tmp/ RUN cp /tmp/requirements.txt /tmp/req.bak \ && awk '!/torch/' /tmp/requirements.txt > /tmp/tmp && mv /tmp/tmp /tmp/requirements.txt \ - && python -m pip install --no-cache-dir --use-feature=2020-resolver -r /tmp/requirements-dev.txt + && python -m pip install --upgrade --no-cache-dir pip \ + && python -m pip install --no-cache-dir -r /tmp/requirements-dev.txt # compile ext and remove temp files # TODO: remark for issue [revise the dockerfile #1276](https://github.com/Project-MONAI/MONAI/issues/1276) diff --git a/docs/requirements.txt b/docs/requirements.txt index 5614e2bf40..d046bc53cf 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,7 +2,7 @@ torch>=1.5 pytorch-ignite==0.4.2 numpy>=1.17 -itk +itk>=5.0 nibabel parameterized scikit-image>=0.14.2 diff --git a/docs/source/apps.rst b/docs/source/apps.rst index f2afd93836..b8c8b4d341 100644 --- a/docs/source/apps.rst +++ b/docs/source/apps.rst @@ -28,3 +28,27 @@ Applications .. autofunction:: extractall .. autofunction:: download_and_extract + +`Deepgrow` +---------- + +.. automodule:: monai.apps.deepgrow.dataset +.. autofunction:: create_dataset + +.. automodule:: monai.apps.deepgrow.interaction +.. autoclass:: Interaction + :members: + +.. automodule:: monai.apps.deepgrow.transforms +.. autoclass:: AddInitialSeedPointd + :members: +.. autoclass:: AddGuidanceSignald + :members: +.. autoclass:: AddRandomGuidanced + :members: +.. autoclass:: SpatialCropForegroundd + :members: +.. autoclass:: FindDiscrepancyRegionsd + :members: +.. autoclass:: FindAllValidSlicesd + :members: diff --git a/docs/source/handlers.rst b/docs/source/handlers.rst index 81d28fb4ac..a629b28b27 100644 --- a/docs/source/handlers.rst +++ b/docs/source/handlers.rst @@ -85,6 +85,9 @@ Training stats handler Tensorboard handlers -------------------- +.. autoclass:: TensorBoardHandler + :members: + .. autoclass:: TensorBoardStatsHandler :members: diff --git a/docs/source/losses.rst b/docs/source/losses.rst index a6aa4d566d..5e19219fee 100644 --- a/docs/source/losses.rst +++ b/docs/source/losses.rst @@ -74,4 +74,12 @@ Registration Losses `GlobalMutualInformationLoss` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. autoclass:: GlobalMutualInformationLoss + :members: + +Loss Wrappers +-------------- + +`MultiScaleLoss` +~~~~~~~~~~~~~~~~~ +.. autoclass:: MultiScaleLoss :members: \ No newline at end of file diff --git a/docs/source/networks.rst b/docs/source/networks.rst index 7c22964835..e0ac0f2d75 100644 --- a/docs/source/networks.rst +++ b/docs/source/networks.rst @@ -120,12 +120,12 @@ Blocks .. autoclass:: SubpixelUpSample `LocalNet DownSample Block` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. autoclass:: LocalNetDownSampleBlock :members: `LocalNet UpSample Block` -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~ .. autoclass:: LocalNetUpSampleBlock :members: @@ -135,10 +135,15 @@ Blocks :members: `Warp` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~ .. autoclass:: Warp :members: +`DVF2DDF` +~~~~~~~~~ +.. autoclass:: DVF2DDF + :members: + Layers ------ @@ -201,7 +206,7 @@ Layers ~~~~~~~~~~~~~~~~ .. autoclass:: GaussianFilter :members: - + `BilateralFilter` ~~~~~~~~~~~~~~~~~ .. autoclass:: BilateralFilter diff --git a/docs/source/transforms.rst b/docs/source/transforms.rst index 90d960a6b9..5b550f7885 100644 --- a/docs/source/transforms.rst +++ b/docs/source/transforms.rst @@ -237,6 +237,12 @@ IO :members: :special-members: __call__ +`SaveImage` +""""""""""" +.. autoclass:: SaveImage + :members: + :special-members: __call__ + Post-processing ^^^^^^^^^^^^^^^ @@ -702,6 +708,12 @@ IO (Dict) :members: :special-members: __call__ +`SaveImaged` +"""""""""""" +.. autoclass:: SaveImaged + :members: + :special-members: __call__ + Post-processing (Dict) ^^^^^^^^^^^^^^^^^^^^^^ @@ -939,6 +951,12 @@ Utility (Dict) :members: :special-members: __call__ +`RandLambdad` +""""""""""""" +.. autoclass:: RandLambdad + :members: + :special-members: __call__ + `LabelToMaskd` """""""""""""" .. autoclass:: LabelToMaskd diff --git a/monai/apps/datasets.py b/monai/apps/datasets.py index d8fd815ce9..f0416b8c4f 100644 --- a/monai/apps/datasets.py +++ b/monai/apps/datasets.py @@ -94,7 +94,9 @@ def __init__( data = self._generate_data_list(dataset_dir) if transform == (): transform = LoadImaged("image") - super().__init__(data, transform, cache_num=cache_num, cache_rate=cache_rate, num_workers=num_workers) + CacheDataset.__init__( + self, data, transform, cache_num=cache_num, cache_rate=cache_rate, num_workers=num_workers + ) def randomize(self, data: Optional[Any] = None) -> None: self.rann = self.R.random() @@ -275,7 +277,9 @@ def __init__( self._properties = load_decathlon_properties(os.path.join(dataset_dir, "dataset.json"), property_keys) if transform == (): transform = LoadImaged(["image", "label"]) - super().__init__(data, transform, cache_num=cache_num, cache_rate=cache_rate, num_workers=num_workers) + CacheDataset.__init__( + self, data, transform, cache_num=cache_num, cache_rate=cache_rate, num_workers=num_workers + ) def get_indices(self) -> np.ndarray: """ diff --git a/monai/apps/deepgrow/__init__.py b/monai/apps/deepgrow/__init__.py new file mode 100644 index 0000000000..14ae193634 --- /dev/null +++ b/monai/apps/deepgrow/__init__.py @@ -0,0 +1,10 @@ +# Copyright 2020 - 2021 MONAI Consortium +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/monai/apps/deepgrow/dataset.py b/monai/apps/deepgrow/dataset.py new file mode 100644 index 0000000000..45cfbde6ea --- /dev/null +++ b/monai/apps/deepgrow/dataset.py @@ -0,0 +1,281 @@ +# Copyright 2020 - 2021 MONAI Consortium +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +import os +from typing import Dict, List + +import numpy as np + +from monai.transforms import AsChannelFirstd, Compose, LoadImaged, Orientationd, Spacingd +from monai.utils import GridSampleMode + + +def create_dataset( + datalist, + output_dir: str, + dimension, + pixdim, + image_key: str = "image", + label_key: str = "label", + base_dir=None, + limit: int = 0, + relative_path: bool = False, + transforms=None, +) -> List[Dict]: + """ + Utility to pre-process and create dataset list for Deepgrow training over on existing one. + The input data list is normally a list of images and labels (3D volume) that needs pre-processing + for Deepgrow training pipeline. + + Args: + datalist: A list of data dictionary. Each entry should at least contain 'image_key': . + For example, typical input data can be a list of dictionaries:: + + [{'image': , 'label':