From 52b3ae55f4d4e84fcdd64ee2814c33ab9957d419 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Tue, 25 Jan 2022 22:03:00 +0000 Subject: [PATCH 1/3] fixes grid_sample, interpolate URLs Signed-off-by: Wenqi Li --- monai/apps/deepgrow/transforms.py | 2 +- monai/data/nifti_saver.py | 6 +- monai/data/nifti_writer.py | 6 +- monai/data/png_saver.py | 2 +- monai/data/png_writer.py | 2 +- monai/handlers/segmentation_saver.py | 6 +- monai/networks/blocks/warp.py | 2 +- monai/networks/layers/spatial_transforms.py | 6 +- monai/transforms/io/array.py | 6 +- monai/transforms/io/dictionary.py | 6 +- monai/transforms/spatial/array.py | 120 ++++++++++---------- monai/transforms/spatial/dictionary.py | 54 ++++----- monai/utils/enums.py | 6 +- 13 files changed, 112 insertions(+), 112 deletions(-) diff --git a/monai/apps/deepgrow/transforms.py b/monai/apps/deepgrow/transforms.py index a4daef70f6..310931d236 100644 --- a/monai/apps/deepgrow/transforms.py +++ b/monai/apps/deepgrow/transforms.py @@ -780,7 +780,7 @@ class RestoreLabeld(MapTransform): One of the listed string values or a user supplied function for padding. Defaults to ``"constant"``. See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html align_corners: Geometrically, we consider the pixels of the input as squares rather than points. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of bool, each element corresponds to a key in ``keys``. meta_keys: explicitly indicate the key of the corresponding meta data dictionary. for example, for data with key `image`, the metadata by default is in `image_meta_dict`. diff --git a/monai/data/nifti_saver.py b/monai/data/nifti_saver.py index f31926cb6c..a5acdd032e 100644 --- a/monai/data/nifti_saver.py +++ b/monai/data/nifti_saver.py @@ -60,13 +60,13 @@ def __init__( mode: {``"bilinear"``, ``"nearest"``} This option is used when ``resample = True``. Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} This option is used when ``resample = True``. Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html align_corners: Geometrically, we consider the pixels of the input as squares rather than points. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision. If None, use the data type of input data. output_dtype: data type for saving data. Defaults to ``np.float32``. diff --git a/monai/data/nifti_writer.py b/monai/data/nifti_writer.py index 35044977e0..4e7a99f557 100644 --- a/monai/data/nifti_writer.py +++ b/monai/data/nifti_writer.py @@ -87,13 +87,13 @@ def write_nifti( mode: {``"bilinear"``, ``"nearest"``} This option is used when ``resample = True``. Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} This option is used when ``resample = True``. Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html align_corners: Geometrically, we consider the pixels of the input as squares rather than points. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision. If None, use the data type of input data. output_dtype: data type for saving data. Defaults to ``np.float32``. diff --git a/monai/data/png_saver.py b/monai/data/png_saver.py index 2e31597837..a83a560e9f 100644 --- a/monai/data/png_saver.py +++ b/monai/data/png_saver.py @@ -52,7 +52,7 @@ def __init__( resample: whether to resample and resize if providing spatial_shape in the metadata. mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``"nearest"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html scale: {``255``, ``65535``} postprocess data by clipping to [0, 1] and scaling [0, 255] (uint8) or [0, 65535] (uint16). Default is None to disable scaling. data_root_dir: if not empty, it specifies the beginning parts of the input file's diff --git a/monai/data/png_writer.py b/monai/data/png_writer.py index 6f3b2ef86e..f1aa5fc5c8 100644 --- a/monai/data/png_writer.py +++ b/monai/data/png_writer.py @@ -39,7 +39,7 @@ def write_png( output_spatial_shape: spatial shape of the output image. mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``"bicubic"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html scale: {``255``, ``65535``} postprocess data by clipping to [0, 1] and scaling to [0, 255] (uint8) or [0, 65535] (uint16). Default is None to disable scaling. diff --git a/monai/handlers/segmentation_saver.py b/monai/handlers/segmentation_saver.py index 79ebfd3a22..40bb5f8bed 100644 --- a/monai/handlers/segmentation_saver.py +++ b/monai/handlers/segmentation_saver.py @@ -72,16 +72,16 @@ def __init__( - NIfTI files {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html - PNG files {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html padding_mode: This option is used when ``resample = True``. Defaults to ``"border"``. - NIfTI files {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html - PNG files This option is ignored. diff --git a/monai/networks/blocks/warp.py b/monai/networks/blocks/warp.py index 79fed14834..9fdaab0a48 100644 --- a/monai/networks/blocks/warp.py +++ b/monai/networks/blocks/warp.py @@ -38,7 +38,7 @@ def __init__(self, mode=GridSampleMode.BILINEAR.value, padding_mode=GridSamplePa - mode: ``"nearest"``, ``"bilinear"``, ``"bicubic"``. - padding_mode: ``"zeros"``, ``"border"``, ``"reflection"`` - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html For MONAI C++/CUDA extensions, the possible values are: diff --git a/monai/networks/layers/spatial_transforms.py b/monai/networks/layers/spatial_transforms.py index 01e45b2e67..7aa3e110fc 100644 --- a/monai/networks/layers/spatial_transforms.py +++ b/monai/networks/layers/spatial_transforms.py @@ -446,11 +446,11 @@ def __init__( coordinates. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"zeros"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample - align_corners: see also https://pytorch.org/docs/stable/nn.functional.html#grid-sample. + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html + align_corners: see also https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html. reverse_indexing: whether to reverse the spatial indexing of image and coordinates. set to `False` if `theta` follows pytorch's default "D, H, W" convention. set to `True` if `theta` follows `scipy.ndimage` default "i, j, k" convention. diff --git a/monai/transforms/io/array.py b/monai/transforms/io/array.py index 19fafbcbf4..f8aa838439 100644 --- a/monai/transforms/io/array.py +++ b/monai/transforms/io/array.py @@ -248,16 +248,16 @@ class SaveImage(Transform): - NIfTI files {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html - PNG files {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html padding_mode: This option is used when ``resample = True``. Defaults to ``"border"``. - NIfTI files {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html - PNG files This option is ignored. diff --git a/monai/transforms/io/dictionary.py b/monai/transforms/io/dictionary.py index 96850ac0cd..cc6a67593f 100644 --- a/monai/transforms/io/dictionary.py +++ b/monai/transforms/io/dictionary.py @@ -170,16 +170,16 @@ class SaveImaged(MapTransform): - NIfTI files {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html - PNG files {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html padding_mode: This option is used when ``resample = True``. Defaults to ``"border"``. - NIfTI files {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html - PNG files This option is ignored. diff --git a/monai/transforms/spatial/array.py b/monai/transforms/spatial/array.py index ee5d179b00..60e4f564c8 100644 --- a/monai/transforms/spatial/array.py +++ b/monai/transforms/spatial/array.py @@ -121,12 +121,12 @@ def __init__( of the original data. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html align_corners: Geometrically, we consider the pixels of the input as squares rather than points. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision. If None, use the data type of input data. To be compatible with other modules, the output data type is always ``np.float32``. @@ -157,12 +157,12 @@ def __call__( affine (matrix): (N+1)x(N+1) original affine matrix for spatially ND `data_array`. Defaults to identity. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``self.padding_mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html align_corners: Geometrically, we consider the pixels of the input as squares rather than points. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html dtype: data type for resampling computation. Defaults to ``self.dtype``. If None, use the data type of input data. To be compatible with other modules, the output data type is always ``np.float32``. @@ -389,10 +389,10 @@ class Resize(Transform): #albumentations.augmentations.geometric.resize.LongestMaxSize. mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``"area"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html align_corners: This only has an effect when mode is 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html """ backend = [TransformBackends.TORCH] @@ -420,10 +420,10 @@ def __call__( img: channel first array, must have shape: (num_channels, H[, W, ..., ]). mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html align_corners: This only has an effect when mode is 'linear', 'bilinear', 'bicubic' or 'trilinear'. Defaults to ``self.align_corners``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html Raises: ValueError: When ``self.spatial_size`` length is less than ``img`` spatial dimensions. @@ -469,12 +469,12 @@ class Rotate(Transform, ThreadUnsafe): input array is contained completely in the output. Default is True. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html align_corners: Defaults to False. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision. If None, use the data type of input data. To be compatible with other modules, the output data type is always ``np.float32``. @@ -512,14 +512,14 @@ def __call__( img: channel first array, must have shape: [chns, H, W] or [chns, H, W, D]. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``self.padding_mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html align_corners: Defaults to ``self.align_corners``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html align_corners: Defaults to ``self.align_corners``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html dtype: data type for resampling computation. Defaults to ``self.dtype``. If None, use the data type of input data. To be compatible with other modules, the output data type is always ``np.float32``. @@ -578,7 +578,7 @@ def get_rotation_matrix(self) -> Optional[NdarrayOrTensor]: class Zoom(Transform): """ Zooms an ND image using :py:class:`torch.nn.functional.interpolate`. - For details, please see https://pytorch.org/docs/stable/nn.functional.html#interpolate. + For details, please see https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html. Different from :py:class:`monai.transforms.resize`, this transform takes scaling factors as input, and provides an option of preserving the input spatial size. @@ -589,7 +589,7 @@ class Zoom(Transform): If a sequence, zoom should contain one value for each spatial axis. mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``"area"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html padding_mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``, ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``} available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}. @@ -599,7 +599,7 @@ class Zoom(Transform): https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html align_corners: This only has an effect when mode is 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html keep_size: Should keep original size (padding/slicing if needed), default is True. kwargs: other arguments for the `np.pad` or `torch.pad` function. note that `np.pad` treats channel dimension as the first dimension. @@ -636,7 +636,7 @@ def __call__( img: channel first array, must have shape: (num_channels, H[, W, ..., ]). mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html padding_mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``, ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``} available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}. @@ -646,7 +646,7 @@ def __call__( https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html align_corners: This only has an effect when mode is 'linear', 'bilinear', 'bicubic' or 'trilinear'. Defaults to ``self.align_corners``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html """ img_t: torch.Tensor @@ -778,12 +778,12 @@ class RandRotate(RandomizableTransform): If it is True, the output shape is the same as the input. Default is True. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html align_corners: Defaults to False. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision. If None, use the data type of input data. To be compatible with other modules, the output data type is always ``np.float32``. @@ -847,12 +847,12 @@ def __call__( img: channel first array, must have shape 2D: (nchannels, H, W), or 3D: (nchannels, H, W, D). mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``self.padding_mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html align_corners: Defaults to ``self.align_corners``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html dtype: data type for resampling computation. Defaults to ``self.dtype``. If None, use the data type of input data. To be compatible with other modules, the output data type is always ``np.float32``. @@ -965,7 +965,7 @@ class RandZoom(RandomizableTransform): If 2 values provided for 3D data, use the first value for both H & W dims to keep the same zoom ratio. mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``"area"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html padding_mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``, ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``} available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}. @@ -975,7 +975,7 @@ class RandZoom(RandomizableTransform): https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html align_corners: This only has an effect when mode is 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html keep_size: Should keep original size (pad if needed), default is True. kwargs: other arguments for the `np.pad` or `torch.pad` function. note that `np.pad` treats channel dimension as the first dimension. @@ -1033,7 +1033,7 @@ def __call__( img: channel first array, must have shape 2D: (nchannels, H, W), or 3D: (nchannels, H, W, D). mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html padding_mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``, ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``} available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}. @@ -1043,7 +1043,7 @@ def __call__( https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html align_corners: This only has an effect when mode is 'linear', 'bilinear', 'bicubic' or 'trilinear'. Defaults to ``self.align_corners``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html randomize: whether to execute `randomize()` function first, default to True. """ @@ -1348,10 +1348,10 @@ def __init__( Args: mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html device: device on which the tensor will be allocated. .. deprecated:: 0.6.0 @@ -1375,10 +1375,10 @@ def __call__( grid: shape must be (3, H, W) for 2D or (4, H, W, D) for 3D. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``self.padding_mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html """ if grid is None: raise ValueError("Unknown grid.") @@ -1484,10 +1484,10 @@ def __init__( to `(32, 64)` if the second spatial dimension size of img is `64`. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"reflection"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html device: device on which the tensor will be allocated. image_only: if True return only the image volume, otherwise return (image, affine). @@ -1526,10 +1526,10 @@ def __call__( if `img` has three spatial dimensions, `spatial_size` should have 3 elements [h, w, d]. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``self.padding_mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html """ sp_size = fall_back_tuple(spatial_size or self.spatial_size, img.shape[1:]) grid, affine = self.affine_grid(spatial_size=sp_size) @@ -1596,10 +1596,10 @@ def __init__( to `(32, 64)` if the second spatial dimension size of img is `64`. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"reflection"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html cache_grid: whether to cache the identity sampling grid. If the spatial size is not dynamically defined by input image, enabling this option could accelerate the transform. @@ -1701,10 +1701,10 @@ def __call__( if `img` has three spatial dimensions, `spatial_size` should have 3 elements [h, w, d]. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``self.padding_mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html randomize: whether to execute `randomize()` function first, default to True. """ @@ -1786,10 +1786,10 @@ def __init__( to `(32, 64)` if the second spatial dimension size of img is `64`. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"reflection"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html device: device on which the tensor will be allocated. See also: @@ -1849,10 +1849,10 @@ def __call__( the transform will use the spatial size of `img`. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``self.padding_mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html randomize: whether to execute `randomize()` function first, default to True. """ sp_size = fall_back_tuple(spatial_size or self.spatial_size, img.shape[1:]) @@ -1942,10 +1942,10 @@ def __init__( to `(32, 32, 64)` if the third spatial dimension size of img is `64`. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"reflection"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html device: device on which the tensor will be allocated. See also: @@ -2009,10 +2009,10 @@ def __call__( the transform will use the spatial size of `img`. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``self.mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``self.padding_mode``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html randomize: whether to execute `randomize()` function first, default to True. """ sp_size = fall_back_tuple(spatial_size or self.spatial_size, img.shape[1:]) @@ -2057,10 +2057,10 @@ def __init__( Each value in the tuple represents the distort step of the related cell. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html device: device on which the tensor will be allocated. """ @@ -2084,10 +2084,10 @@ def __call__( Each value in the tuple represents the distort step of the related cell. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html """ distort_steps = self.distort_steps if distort_steps is None else distort_steps @@ -2145,10 +2145,10 @@ def __init__( Defaults to (-0.03, 0.03). mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html device: device on which the tensor will be allocated. """ @@ -2184,10 +2184,10 @@ def __call__( img: shape must be (num_channels, H, W[, D]). mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html randomize: whether to shuffle the random factors using `randomize()`, default to True. """ if randomize: diff --git a/monai/transforms/spatial/dictionary.py b/monai/transforms/spatial/dictionary.py index 0ab9210aaf..963015f420 100644 --- a/monai/transforms/spatial/dictionary.py +++ b/monai/transforms/spatial/dictionary.py @@ -183,14 +183,14 @@ def __init__( axes against the original ones. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. align_corners: Geometrically, we consider the pixels of the input as squares rather than points. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of bool, each element corresponds to a key in ``keys``. dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision. If None, use the data type of input data. To be compatible with other modules, @@ -526,11 +526,11 @@ class Resized(MapTransform, InvertibleTransform): #albumentations.augmentations.geometric.resize.LongestMaxSize. mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``"area"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html It also can be a sequence of string, each element corresponds to a key in ``keys``. align_corners: This only has an effect when mode is 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html It also can be a sequence of bool or None, each element corresponds to a key in ``keys``. allow_missing_keys: don't raise exception if key is missing. """ @@ -639,11 +639,11 @@ def __init__( to `(32, 64)` if the second spatial dimension size of img is `64`. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"reflection"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. device: device on which the tensor will be allocated. allow_missing_keys: don't raise exception if key is missing. @@ -769,11 +769,11 @@ def __init__( This allows 0 to correspond to no change (i.e., a scaling of 1.0). mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"reflection"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. cache_grid: whether to cache the identity sampling grid. If the spatial size is not dynamically defined by input image, enabling this option could @@ -939,11 +939,11 @@ def __init__( This allows 0 to correspond to no change (i.e., a scaling of 1.0). mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"reflection"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. device: device on which the tensor will be allocated. allow_missing_keys: don't raise exception if key is missing. @@ -1075,11 +1075,11 @@ def __init__( This allows 0 to correspond to no change (i.e., a scaling of 1.0). mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"reflection"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. device: device on which the tensor will be allocated. allow_missing_keys: don't raise exception if key is missing. @@ -1311,14 +1311,14 @@ class Rotated(MapTransform, InvertibleTransform): If it is True, the output shape is the same as the input. Default is True. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. align_corners: Defaults to False. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of bool, each element corresponds to a key in ``keys``. dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision. If None, use the data type of input data. To be compatible with other modules, @@ -1422,14 +1422,14 @@ class RandRotated(RandomizableTransform, MapTransform, InvertibleTransform): If it is True, the output shape is the same as the input. Default is True. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"border"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. align_corners: Defaults to False. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html It also can be a sequence of bool, each element corresponds to a key in ``keys``. dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision. If None, use the data type of input data. To be compatible with other modules, @@ -1548,7 +1548,7 @@ class Zoomd(MapTransform, InvertibleTransform): If a sequence, zoom should contain one value for each spatial axis. mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``"area"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``, ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``} @@ -1559,7 +1559,7 @@ class Zoomd(MapTransform, InvertibleTransform): https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html align_corners: This only has an effect when mode is 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html It also can be a sequence of bool or None, each element corresponds to a key in ``keys``. keep_size: Should keep original size (pad if needed), default is True. allow_missing_keys: don't raise exception if key is missing. @@ -1648,7 +1648,7 @@ class RandZoomd(RandomizableTransform, MapTransform, InvertibleTransform): If 2 values provided for 3D data, use the first value for both H & W dims to keep the same zoom ratio. mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``, ``"area"``} The interpolation mode. Defaults to ``"area"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: available modes for numpy array:{``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``, ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``} @@ -1659,7 +1659,7 @@ class RandZoomd(RandomizableTransform, MapTransform, InvertibleTransform): https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html align_corners: This only has an effect when mode is 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None. - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html It also can be a sequence of bool or None, each element corresponds to a key in ``keys``. keep_size: Should keep original size (pad if needed), default is True. allow_missing_keys: don't raise exception if key is missing. @@ -1779,11 +1779,11 @@ def __init__( Each value in the tuple represents the distort step of the related cell. mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"reflection"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. device: device on which the tensor will be allocated. allow_missing_keys: don't raise exception if key is missing. @@ -1829,11 +1829,11 @@ def __init__( Defaults to (-0.03, 0.03). mode: {``"bilinear"``, ``"nearest"``} Interpolation mode to calculate output values. Defaults to ``"bilinear"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} Padding mode for outside grid values. Defaults to ``"reflection"``. - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html It also can be a sequence of string, each element corresponds to a key in ``keys``. device: device on which the tensor will be allocated. allow_missing_keys: don't raise exception if key is missing. diff --git a/monai/utils/enums.py b/monai/utils/enums.py index e1fff184fc..93a6d8f49e 100644 --- a/monai/utils/enums.py +++ b/monai/utils/enums.py @@ -58,7 +58,7 @@ class NumpyPadMode(Enum): class GridSampleMode(Enum): """ - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html interpolation mode of `torch.nn.functional.grid_sample` @@ -76,7 +76,7 @@ class GridSampleMode(Enum): class InterpolateMode(Enum): """ - See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html """ NEAREST = "nearest" @@ -119,7 +119,7 @@ class PytorchPadMode(Enum): class GridSamplePadMode(Enum): """ - See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html """ ZEROS = "zeros" From a77c902cb5302b6f15f173f98c7dbb18fe8c6721 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Wed, 26 Jan 2022 10:31:29 +0000 Subject: [PATCH 2/3] update based on comments Signed-off-by: Wenqi Li --- monai/inferers/inferer.py | 2 +- monai/inferers/utils.py | 2 +- monai/networks/blocks/upsample.py | 2 +- monai/transforms/croppad/dictionary.py | 4 ++-- monai/utils/enums.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/monai/inferers/inferer.py b/monai/inferers/inferer.py index 0b700d7c2e..f275480352 100644 --- a/monai/inferers/inferer.py +++ b/monai/inferers/inferer.py @@ -110,7 +110,7 @@ class SlidingWindowInferer(Inferer): spatial dimensions. padding_mode: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``} Padding mode when ``roi_size`` is larger than inputs. Defaults to ``"constant"`` - See also: https://pytorch.org/docs/stable/nn.functional.html#pad + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html cval: fill value for 'constant' padding mode. Default: 0 sw_device: device for the window data. By default the device (and accordingly the memory) of the `inputs` is used. diff --git a/monai/inferers/utils.py b/monai/inferers/utils.py index b27e13eef6..65a81378fa 100644 --- a/monai/inferers/utils.py +++ b/monai/inferers/utils.py @@ -65,7 +65,7 @@ def sliding_window_inference( spatial dimensions. padding_mode: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``} Padding mode for ``inputs``, when ``roi_size`` is larger than inputs. Defaults to ``"constant"`` - See also: https://pytorch.org/docs/stable/nn.functional.html#pad + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html cval: fill value for 'constant' padding mode. Default: 0 sw_device: device for the window data. By default the device (and accordingly the memory) of the `inputs` is used. diff --git a/monai/networks/blocks/upsample.py b/monai/networks/blocks/upsample.py index 6a8498fe6f..c72d1bc518 100644 --- a/monai/networks/blocks/upsample.py +++ b/monai/networks/blocks/upsample.py @@ -72,7 +72,7 @@ def __init__( If ends with ``"linear"`` will use ``spatial dims`` to determine the correct interpolation. This corresponds to linear, bilinear, trilinear for 1D, 2D, and 3D respectively. The interpolation mode. Defaults to ``"linear"``. - See also: https://pytorch.org/docs/stable/nn.html#upsample + See also: https://pytorch.org/docs/stable/generated/torch.nn.Upsample.html align_corners: set the align_corners parameter of `torch.nn.Upsample`. Defaults to True. Only used in the "nontrainable" mode. bias: whether to have a bias term in the default preconv and deconv layers. Defaults to True. diff --git a/monai/transforms/croppad/dictionary.py b/monai/transforms/croppad/dictionary.py index 482247bbe9..d62d6fbdcb 100644 --- a/monai/transforms/croppad/dictionary.py +++ b/monai/transforms/croppad/dictionary.py @@ -287,8 +287,8 @@ def __init__( ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``} available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}. One of the listed string values or a user supplied function. Defaults to ``"constant"``. - See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html - https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html + See also: https://numpy.org/doc/1.18/reference/ghttps://pytorch.orgenerated/numpy.pad.html + /docs/stable/generated/torch.nn.functional.pad.html It also can be a sequence of string, each element corresponds to a key in ``keys``. method: {``"symmetric"``, ``"end"``} Pad image symmetrically on every side or only pad at the end sides. Defaults to ``"symmetric"``. diff --git a/monai/utils/enums.py b/monai/utils/enums.py index 93a6d8f49e..f88a606fb2 100644 --- a/monai/utils/enums.py +++ b/monai/utils/enums.py @@ -108,7 +108,7 @@ class BlendMode(Enum): class PytorchPadMode(Enum): """ - See also: https://pytorch.org/docs/stable/nn.functional.html#pad + See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html """ CONSTANT = "constant" From 9a584ebeda02a7d780a9a6f4b2d7e811fcc51909 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Wed, 26 Jan 2022 11:05:01 +0000 Subject: [PATCH 3/3] skip if pretrained downloading failed Signed-off-by: Wenqi Li --- tests/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/utils.py b/tests/utils.py index 17297e53f3..232c9c9030 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -101,6 +101,8 @@ def test_pretrained_networks(network, input_param, device): except RuntimeError as r_error: if "unexpected EOF" in f"{r_error}": # The file might be corrupted. raise unittest.SkipTest(f"{r_error}") from r_error + if "network issue" in f"{r_error}": # The network is not available. + raise unittest.SkipTest(f"{r_error}") from r_error raise