Skip to content

Commit

Permalink
Merge branch 'dev' into 8134-add-realtime-infer
Browse files Browse the repository at this point in the history
  • Loading branch information
KumoLiu authored Nov 21, 2024
2 parents 5797465 + 13b96ae commit a4c8095
Show file tree
Hide file tree
Showing 75 changed files with 1,297 additions and 235 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/blossom-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ jobs:
(
github.actor == 'Nic-Ma' ||
github.actor == 'wyli' ||
github.actor == 'pxLi' ||
github.actor == 'YanxuanLiu' ||
github.actor == 'wendell-hom' ||
github.actor == 'KumoLiu'
)
steps:
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
- "PT110+CUDA113"
- "PT113+CUDA118"
- "PT210+CUDA121"
- "PTLATEST+CUDA124"
- "PT240+CUDA126"
- "PTLATEST+CUDA126"
include:
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes
- environment: PT110+CUDA113
Expand All @@ -28,9 +29,12 @@ jobs:
- environment: PT210+CUDA121
pytorch: "pytorch==2.1.0 torchvision==0.16.0 --extra-index-url https://download.pytorch.org/whl/cu121"
base: "nvcr.io/nvidia/pytorch:23.08-py3" # CUDA 12.1
- environment: PTLATEST+CUDA124
- environment: PT240+CUDA126
pytorch: "pytorch==2.4.0 torchvision==0.19.0 --extra-index-url https://download.pytorch.org/whl/cu121"
base: "nvcr.io/nvidia/pytorch:24.08-py3" # CUDA 12.6
- environment: PTLATEST+CUDA126
pytorch: "-U torch torchvision --extra-index-url https://download.pytorch.org/whl/cu121"
base: "nvcr.io/nvidia/pytorch:24.08-py3" # CUDA 12.4
base: "nvcr.io/nvidia/pytorch:24.10-py3" # CUDA 12.6
container:
image: ${{ matrix.base }}
options: "--gpus all"
Expand Down Expand Up @@ -80,7 +84,7 @@ jobs:
if: github.repository == 'Project-MONAI/MONAI'
strategy:
matrix:
container: ["pytorch:23.08", "pytorch:24.08"]
container: ["pytorch:23.08", "pytorch:24.08", "pytorch:24.10"]
container:
image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image
options: "--gpus all"
Expand Down Expand Up @@ -129,7 +133,7 @@ jobs:
if: github.repository == 'Project-MONAI/MONAI'
strategy:
matrix:
container: ["pytorch:24.08"]
container: ["pytorch:24.10"]
container:
image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image
options: "--gpus all"
Expand Down Expand Up @@ -233,7 +237,7 @@ jobs:
if: github.repository == 'Project-MONAI/MONAI'
needs: cron-gpu # so that monai itself is verified first
container:
image: nvcr.io/nvidia/pytorch:24.08-py3 # testing with the latest pytorch base image
image: nvcr.io/nvidia/pytorch:24.10-py3 # testing with the latest pytorch base image
options: "--gpus all --ipc=host"
runs-on: [self-hosted, linux, x64, integration]
steps:
Expand Down
23 changes: 10 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -26,33 +26,30 @@ repos:
args: ['--autofix', '--no-sort-keys', '--indent=4']
- id: end-of-file-fixer
- id: mixed-line-ending
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.5
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
hooks:
- id: ruff
args:
- --fix

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.19.0
hooks:
- id: pyupgrade
args: [--py37-plus]
name: Upgrade code excluding monai networks
args: [--py39-plus, --keep-runtime-typing]
name: Upgrade code with exceptions
exclude: |
(?x)(
^versioneer.py|
^monai/_version.py|
^monai/networks/| # no PEP 604 for torchscript tensorrt
^monai/losses/ # no PEP 604 for torchscript tensorrt
^monai/networks/| # avoid typing rewrites
^monai/apps/detection/utils/anchor_utils.py| # avoid typing rewrites
^tests/test_compute_panoptic_quality.py # avoid typing rewrites
)
- id: pyupgrade
args: [--py37-plus, --keep-runtime-typing]
name: Upgrade monai networks
files: (?x)(^monai/networks/)
- repo: https://github.com/asottile/yesqa
rev: v1.4.0
rev: v1.5.0
hooks:
- id: yesqa
name: Unused noqa
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [Unreleased]

## [1.4.0] - 2024-10-14
## [1.4.0] - 2024-10-17
## What's Changed
### Added
* Implemented Conjugate Gradient Solver to generate confidence maps. (#7876)
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: "MONAI: Medical Open Network for AI"
abstract: "AI Toolkit for Healthcare Imaging"
authors:
- name: "MONAI Consortium"
date-released: 2024-10-14
date-released: 2024-10-17
version: "1.4.0"
identifiers:
- description: "This DOI represents all versions of MONAI, and will always resolve to the latest one."
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,8 @@ then make PRs to the `releasing/[version number]` to fix the bugs via the regula
If any error occurs after the release process, first check out a new hotfix branch from the `main` branch,
make a patch version release following the semantic versioning, for example, `releasing/0.1.1`.
Make sure the `releasing/0.1.1` is merged back into both `dev` and `main` and all the test pipelines succeed.


<p align="right">
<a href="#introduction">⬆️ Back to Top</a>
</p>
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# To build with a different base image
# please run `docker build` using the `--build-arg PYTORCH_IMAGE=...` flag.
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:24.08-py3
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:24.10-py3
FROM ${PYTORCH_IMAGE}

LABEL maintainer="[email protected]"
Expand Down Expand Up @@ -41,6 +41,10 @@ RUN cp /tmp/requirements.txt /tmp/req.bak \
COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md versioneer.py setup.py setup.cfg runtests.sh MANIFEST.in ./
COPY tests ./tests
COPY monai ./monai

# TODO: remove this line and torch.patch for 24.11
RUN patch -R -d /usr/local/lib/python3.10/dist-packages/torch/onnx/ < ./monai/torch.patch

RUN BUILD_MONAI=1 FORCE_CUDA=1 python setup.py develop \
&& rm -rf build __pycache__

Expand All @@ -57,4 +61,6 @@ RUN apt-get update \
# append /opt/tools to runtime path for NGC CLI to be accessible from all file system locations
ENV PATH=${PATH}:/opt/tools
ENV POLYGRAPHY_AUTOINSTALL_DEPS=1


WORKDIR /opt/monai
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
[![codecov](https://codecov.io/gh/Project-MONAI/MONAI/branch/dev/graph/badge.svg?token=6FTC7U1JJ4)](https://codecov.io/gh/Project-MONAI/MONAI)
[![monai Downloads Last Month](https://assets.piptrends.com/get-last-month-downloads-badge/monai.svg 'monai Downloads Last Month by pip Trends')](https://piptrends.com/package/monai)

MONAI is a [PyTorch](https://pytorch.org/)-based, [open-source](https://github.com/Project-MONAI/MONAI/blob/dev/LICENSE) framework for deep learning in healthcare imaging, part of [PyTorch Ecosystem](https://pytorch.org/ecosystem/).
Its ambitions are:
- developing a community of academic, industrial and clinical researchers collaborating on a common foundation;
- creating state-of-the-art, end-to-end training workflows for healthcare imaging;
- providing researchers with the optimized and standardized way to create and evaluate deep learning models.
MONAI is a [PyTorch](https://pytorch.org/)-based, [open-source](https://github.com/Project-MONAI/MONAI/blob/dev/LICENSE) framework for deep learning in healthcare imaging, part of the [PyTorch Ecosystem](https://pytorch.org/ecosystem/).
Its ambitions are as follows:
- Developing a community of academic, industrial and clinical researchers collaborating on a common foundation;
- Creating state-of-the-art, end-to-end training workflows for healthcare imaging;
- Providing researchers with the optimized and standardized way to create and evaluate deep learning models.


## Features
Expand Down
4 changes: 2 additions & 2 deletions monai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

from __future__ import annotations

import logging
import os
import sys
import logging
import warnings
from ._version import get_versions

from ._version import get_versions

old_showwarning = warnings.showwarning

Expand Down
4 changes: 2 additions & 2 deletions monai/apps/detection/networks/retinanet_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import math
import warnings
from collections.abc import Callable, Sequence
from typing import Any, Dict
from typing import Any

import torch
from torch import Tensor, nn
Expand Down Expand Up @@ -330,7 +330,7 @@ def forward(self, images: Tensor) -> Any:
features = self.feature_extractor(images)
if isinstance(features, Tensor):
feature_maps = [features]
elif torch.jit.isinstance(features, Dict[str, Tensor]):
elif torch.jit.isinstance(features, dict[str, Tensor]):
feature_maps = list(features.values())
else:
feature_maps = list(features)
Expand Down
3 changes: 2 additions & 1 deletion monai/apps/detection/transforms/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

from __future__ import annotations

from typing import Any, Sequence
from collections.abc import Sequence
from typing import Any

import numpy as np
import torch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import gc
import logging
from typing import Sequence
from collections.abc import Sequence

import torch
import torch.nn as nn
Expand Down
2 changes: 1 addition & 1 deletion monai/apps/generation/maisi/networks/controlnet_maisi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from __future__ import annotations

from typing import Sequence
from collections.abc import Sequence

import torch

Expand Down
3 changes: 2 additions & 1 deletion monai/apps/pathology/engines/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

from __future__ import annotations

from typing import Any, Sequence
from collections.abc import Sequence
from typing import Any

import torch

Expand Down
3 changes: 2 additions & 1 deletion monai/apps/pathology/inferers/inferer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

from __future__ import annotations

from typing import Any, Callable, Sequence
from collections.abc import Sequence
from typing import Any, Callable

import numpy as np
import torch
Expand Down
3 changes: 2 additions & 1 deletion monai/apps/pathology/metrics/lesion_froc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Iterable
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion monai/apps/pathology/transforms/post/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from __future__ import annotations

import warnings
from typing import Callable, Sequence
from collections.abc import Sequence
from typing import Callable

import numpy as np
import torch
Expand Down
2 changes: 1 addition & 1 deletion monai/apps/tcia/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from __future__ import annotations

import os
from typing import Iterable
from collections.abc import Iterable

import monai
from monai.config.type_definitions import PathLike
Expand Down
5 changes: 1 addition & 4 deletions monai/apps/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ def check_hash(filepath: PathLike, val: str | None = None, hash_type: str = "md5
return True
actual_hash_func = look_up_option(hash_type.lower(), SUPPORTED_HASH_TYPES)

if sys.version_info >= (3, 9):
actual_hash = actual_hash_func(usedforsecurity=False) # allows checks on FIPS enabled machines
else:
actual_hash = actual_hash_func()
actual_hash = actual_hash_func(usedforsecurity=False) # allows checks on FIPS enabled machines

try:
with open(filepath, "rb") as f:
Expand Down
2 changes: 1 addition & 1 deletion monai/apps/vista3d/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from __future__ import annotations

import warnings
from typing import Sequence
from collections.abc import Sequence

import numpy as np
import torch
Expand Down
4 changes: 2 additions & 2 deletions monai/bundle/reference_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

import re
import warnings
from collections.abc import Sequence
from typing import Any, Iterator
from collections.abc import Iterator, Sequence
from typing import Any

from monai.bundle.config_item import ConfigComponent, ConfigExpression, ConfigItem
from monai.bundle.utils import DEPRECATED_ID_MAPPING, ID_REF_KEY, ID_SEP_KEY
Expand Down
5 changes: 3 additions & 2 deletions monai/bundle/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,8 @@ def trt_export(
"""
Export the model checkpoint to the given filepath as a TensorRT engine-based TorchScript.
Currently, this API only supports converting models whose inputs are all tensors.
Note: NVIDIA Volta support (GPUs with compute capability 7.0) has been removed starting with TensorRT 10.5.
Review the TensorRT Support Matrix for which GPUs are supported.
There are two ways to export a model:
1, Torch-TensorRT way: PyTorch module ---> TorchScript module ---> TensorRT engine-based TorchScript.
Expand Down Expand Up @@ -1945,7 +1947,6 @@ def create_workflow(
"""
_args = update_kwargs(args=args_file, workflow_name=workflow_name, config_file=config_file, **kwargs)
_log_input_summary(tag="run", args=_args)
(workflow_name, config_file) = _pop_args(
_args, workflow_name=ConfigWorkflow, config_file=None
) # the default workflow name is "ConfigWorkflow"
Expand All @@ -1969,7 +1970,7 @@ def create_workflow(
workflow_ = workflow_class(**_args)

workflow_.initialize()

_log_input_summary(tag="run", args=_args)
return workflow_


Expand Down
5 changes: 3 additions & 2 deletions monai/bundle/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
import sys
import time
from abc import ABC, abstractmethod
from collections.abc import Sequence
from copy import copy
from logging.config import fileConfig
from pathlib import Path
from typing import Any, Sequence
from typing import Any

from monai.apps.utils import get_logger
from monai.bundle.config_parser import ConfigParser
Expand Down Expand Up @@ -316,8 +317,8 @@ def __init__(
else:
raise FileNotFoundError(f"Cannot find the logging config file: {logging_file}.")
else:
logger.info(f"Setting logging properties based on config: {logging_file}.")
fileConfig(str(logging_file), disable_existing_loggers=False)
logger.info(f"Setting logging properties based on config: {logging_file}.")

self.parser = ConfigParser()
self.parser.read_config(f=config_file)
Expand Down
3 changes: 2 additions & 1 deletion monai/config/type_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from __future__ import annotations

import os
from typing import Collection, Hashable, Iterable, Sequence, TypeVar, Union
from collections.abc import Collection, Hashable, Iterable, Sequence
from typing import TypeVar, Union

import numpy as np
import torch
Expand Down
Loading

0 comments on commit a4c8095

Please sign in to comment.