From 85ed7a94ddd2339d63c1a6c2d2e11fbf2fc8f07f Mon Sep 17 00:00:00 2001 From: skdas20 Date: Sun, 22 Feb 2026 19:32:04 +0000 Subject: [PATCH 1/2] fix: support more dtypes in pad_nd function - Removes hardcoded dtype exclusion list from pad_nd() - Enables torch.nn.functional.pad for bool and integer dtypes - Try-except fallback to numpy still handles unsupported combinations - Fixes #7842 --- monai/transforms/croppad/functional.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/monai/transforms/croppad/functional.py b/monai/transforms/croppad/functional.py index 653db43bc5..572d01ea1d 100644 --- a/monai/transforms/croppad/functional.py +++ b/monai/transforms/croppad/functional.py @@ -96,12 +96,7 @@ def pad_nd( return _np_pad(img, pad_width=to_pad, mode=mode, **kwargs) try: _pad = _np_pad - if mode in {"constant", "reflect", "edge", "replicate", "wrap", "circular"} and img.dtype not in { - torch.int16, - torch.int64, - torch.bool, - torch.uint8, - }: + if mode in {"constant", "reflect", "edge", "replicate", "wrap", "circular"}: _pad = _pt_pad return _pad(img, pad_width=to_pad, mode=mode, **kwargs) except (ValueError, TypeError, RuntimeError) as err: From 58e774d9ee7436c823aef8f5cdc66aa37fc425f0 Mon Sep 17 00:00:00 2001 From: skdas20 Date: Sun, 22 Feb 2026 19:34:28 +0000 Subject: [PATCH 2/2] improve: add helpful error message for missing tensorboard package - Checks if tensorboard is installed before attempting to create SummaryWriter - Provides installation instructions when tensorboard is missing - Improves user experience for debugging missing dependencies - Addresses issue #7980 Signed-off-by: skdas20 --- monai/handlers/tensorboard_handlers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/monai/handlers/tensorboard_handlers.py b/monai/handlers/tensorboard_handlers.py index 20e2d74c8c..0a69ccfaba 100644 --- a/monai/handlers/tensorboard_handlers.py +++ b/monai/handlers/tensorboard_handlers.py @@ -50,6 +50,11 @@ class TensorBoardHandler: def __init__(self, summary_writer: SummaryWriter | SummaryWriterX | None = None, log_dir: str = "./runs"): if summary_writer is None: + if SummaryWriter is None: + raise RuntimeError( + "TensorBoardHandler requires tensorboard to be installed. " + "Please install it with: pip install tensorboard" + ) self._writer = SummaryWriter(log_dir=log_dir) self.internal_writer = True else: