diff --git a/monai/apps/auto3dseg/bundle_gen.py b/monai/apps/auto3dseg/bundle_gen.py index 462452007f..1831e9f840 100644 --- a/monai/apps/auto3dseg/bundle_gen.py +++ b/monai/apps/auto3dseg/bundle_gen.py @@ -35,7 +35,7 @@ from monai.utils import ensure_tuple logger = get_logger(module_name=__name__) -ALGO_HASH = os.environ.get("MONAI_ALGO_HASH", "d8bec42") +ALGO_HASH = os.environ.get("MONAI_ALGO_HASH", "4af80e1") __all__ = ["BundleAlgo", "BundleGen"] diff --git a/monai/apps/nnunet/__main__.py b/monai/apps/nnunet/__main__.py index 9e4ca5d073..14e2dca8d3 100644 --- a/monai/apps/nnunet/__main__.py +++ b/monai/apps/nnunet/__main__.py @@ -8,7 +8,6 @@ # 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. - """ Examples: - User can use the one-liner to start the nnU-Net workflow @@ -85,7 +84,6 @@ """ - from __future__ import annotations from monai.apps.nnunet.nnunetv2_runner import nnUNetV2Runner diff --git a/monai/apps/nnunet/utils.py b/monai/apps/nnunet/utils.py index 773b9891c0..f49a9b76e9 100644 --- a/monai/apps/nnunet/utils.py +++ b/monai/apps/nnunet/utils.py @@ -25,7 +25,6 @@ logger = monai.apps.utils.get_logger(__name__) - __all__ = ["analyze_data", "create_new_data_copy", "create_new_dataset_json", "NNUNETMode"] diff --git a/monai/metrics/meandice.py b/monai/metrics/meandice.py index 16eebdd28c..97a26f6a4e 100644 --- a/monai/metrics/meandice.py +++ b/monai/metrics/meandice.py @@ -205,7 +205,7 @@ def compute_channel(self, y_pred: torch.Tensor, y: torch.Tensor) -> torch.Tensor denorm = y_o + torch.sum(y_pred) if denorm <= 0: return torch.tensor(1.0, device=y_o.device) - return (2.0 * torch.sum(torch.masked_select(y, y_pred))) / denorm + return torch.tensor(0.0, device=y_o.device) def __call__(self, y_pred: torch.Tensor, y: torch.Tensor) -> torch.Tensor | tuple[torch.Tensor, torch.Tensor]: """ diff --git a/monai/networks/nets/basic_unet.py b/monai/networks/nets/basic_unet.py index b26fdcb622..a29d620ced 100644 --- a/monai/networks/nets/basic_unet.py +++ b/monai/networks/nets/basic_unet.py @@ -12,6 +12,7 @@ from __future__ import annotations from collections.abc import Sequence +from typing import Any import torch import torch.nn as nn @@ -149,16 +150,16 @@ def __init__( self.convs = TwoConv(spatial_dims, cat_chns + up_chns, out_chns, act, norm, bias, dropout) self.is_pad = is_pad - def forward(self, x: torch.Tensor, x_e: torch.Tensor | None): + def forward(self, x: torch.Tensor, x_e: Any): """ Args: x: features to be upsampled. - x_e: features from the encoder. + x_e: optional features from the encoder, if None, this branch is not in use. """ x_0 = self.upsample(x) - if x_e is not None: + if torch.jit.isinstance(x_e, torch.Tensor): if self.is_pad: # handling spatial shapes due to the 2x maxpooling with odd edge lengths. dimensions = len(x.shape) - 2 diff --git a/monai/networks/nets/flexible_unet.py b/monai/networks/nets/flexible_unet.py index a880cafdc3..ac2124b5f9 100644 --- a/monai/networks/nets/flexible_unet.py +++ b/monai/networks/nets/flexible_unet.py @@ -232,6 +232,7 @@ def __init__( dropout: float | tuple = 0.0, decoder_bias: bool = False, upsample: str = "nontrainable", + pre_conv: str = "default", interp_mode: str = "nearest", is_pad: bool = True, ) -> None: @@ -262,6 +263,8 @@ def __init__( decoder_bias: whether to have a bias term in decoder's convolution blocks. upsample: upsampling mode, available options are``"deconv"``, ``"pixelshuffle"``, ``"nontrainable"``. + pre_conv:a conv block applied before upsampling. Only used in the "nontrainable" or + "pixelshuffle" mode, default to `default`. interp_mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``} Only used in the "nontrainable" mode. is_pad: whether to pad upsampling features to fit features from encoder. Default to True. @@ -309,7 +312,7 @@ def __init__( bias=decoder_bias, upsample=upsample, interp_mode=interp_mode, - pre_conv="default", + pre_conv=pre_conv, align_corners=None, is_pad=is_pad, )