Nic-Ma: /black
diff --git a/docs/source/transforms.rst b/docs/source/transforms.rst
index b6e0190f..f4e02b01 100644
--- a/docs/source/transforms.rst
+++ b/docs/source/transforms.rst
@@ -97,6 +97,12 @@ Vanilla Transforms
     :members:
     :special-members: __call__
 
+`ToNumpy`
+~~~~~~~~~
+.. autoclass:: ToNumpy
+    :members:
+    :special-members: __call__
+
 `Transpose`
 ~~~~~~~~~~~
 .. autoclass:: Transpose
@@ -395,6 +401,12 @@ Dictionary-based Transforms
     :members:
     :special-members: __call__
 
+`ToNumpyd`
+~~~~~~~~~~
+.. autoclass:: ToNumpyd
+    :members:
+    :special-members: __call__
+
 `Rotate90d`
 ~~~~~~~~~~~
 .. autoclass:: Rotate90d
diff --git a/monai/transforms/utility/array.py b/monai/transforms/utility/array.py
index 1de1c6d6..b11154c6 100644
--- a/monai/transforms/utility/array.py
+++ b/monai/transforms/utility/array.py
@@ -134,6 +134,17 @@ class ToTensor(Transform):
         return torch.as_tensor(np.ascontiguousarray(img))
 
 
+class ToNumpy(Transform):
+    """
+    Converts the input Tensor data to numpy array.
+    """
+
+    def __call__(self, img):
+        if torch.is_tensor(img):
+            img = img.detach().cpu().numpy()
+        return np.ascontiguousarray(img)
+
+
 class Transpose(Transform):
     """
     Transposes the input image based on the given `indices` dimension ordering.
diff --git a/monai/transforms/utility/dictionary.py b/monai/transforms/utility/dictionary.py
index aa942d1c..dd7bae4a 100644
--- a/monai/transforms/utility/dictionary.py
+++ b/monai/transforms/utility/dictionary.py
@@ -26,6 +26,7 @@ from monai.transforms.utility.array import (
     AddChannel,
     AsChannelFirst,
     ToTensor,
+    ToNumpy,
     AsChannelLast,
     CastToType,
     RepeatChannel,
@@ -165,6 +166,27 @@ class ToTensord(MapTransform):
         return d
 
 
+class ToNumpyd(MapTransform):
+    """
+    Dictionary-based wrapper of :py:class:`monai.transforms.ToNumpy`.
+    """
+
+    def __init__(self, keys: Hashable):
+        """
+        Args:
+            keys (hashable items): keys of the corresponding items to be transformed.
+                See also: :py:class:`monai.transforms.compose.MapTransform`
+        """
+        super().__init__(keys)
+        self.converter = ToNumpy()
+
+    def __call__(self, data):
+        d = dict(data)
+        for key in self.keys:
+            d[key] = self.converter(d[key])
+        return d
+
+
 class DeleteKeysd(MapTransform):
     """
     Delete specified keys from data dictionary to release memory.

Add ToNumpy transform to support 3rd party transforms
**Is your feature request related to a problem? Please describe.**
As we already have `ToTensor` transform to connect other 3rd party transforms that work for Tensor data only, we also need the `ToNumpy` transform to convert back to numpy.

diff --git a/tests/test_to_numpy.py b/tests/test_to_numpy.py
new file mode 100644
index 00000000..fa41ac2b
--- /dev/null
+++ b/tests/test_to_numpy.py
@@ -0,0 +1,39 @@
+# Copyright 2020 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 unittest
+import torch
+import numpy as np
+from monai.transforms import ToNumpy
+
+
+class TestToNumpy(unittest.TestCase):
+    def test_numpy_input(self):
+        test_data = np.array([[1, 2], [3, 4]])
+        test_data = np.rot90(test_data)
+        self.assertFalse(test_data.flags["C_CONTIGUOUS"])
+        result = ToNumpy()(test_data)
+        self.assertTrue(isinstance(result, np.ndarray))
+        self.assertTrue(result.flags["C_CONTIGUOUS"])
+        np.testing.assert_allclose(result, test_data)
+
+    def test_tensor_input(self):
+        test_data = torch.tensor([[1, 2], [3, 4]])
+        test_data = test_data.rot90()
+        self.assertFalse(test_data.is_contiguous())
+        result = ToNumpy()(test_data)
+        self.assertTrue(isinstance(result, np.ndarray))
+        self.assertTrue(result.flags["C_CONTIGUOUS"])
+        np.testing.assert_allclose(result, test_data.numpy())
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/tests/test_to_numpyd.py b/tests/test_to_numpyd.py
new file mode 100644
index 00000000..c9bb4039
--- /dev/null
+++ b/tests/test_to_numpyd.py
@@ -0,0 +1,39 @@
+# Copyright 2020 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 unittest
+import torch
+import numpy as np
+from monai.transforms import ToNumpyd
+
+
+class TestToNumpyd(unittest.TestCase):
+    def test_numpy_input(self):
+        test_data = np.array([[1, 2], [3, 4]])
+        test_data = np.rot90(test_data)
+        self.assertFalse(test_data.flags["C_CONTIGUOUS"])
+        result = ToNumpyd(keys="img")({"img": test_data})["img"]
+        self.assertTrue(isinstance(result, np.ndarray))
+        self.assertTrue(result.flags["C_CONTIGUOUS"])
+        np.testing.assert_allclose(result, test_data)
+
+    def test_tensor_input(self):
+        test_data = torch.tensor([[1, 2], [3, 4]])
+        test_data = test_data.rot90()
+        self.assertFalse(test_data.is_contiguous())
+        result = ToNumpyd(keys="img")({"img": test_data})["img"]
+        self.assertTrue(isinstance(result, np.ndarray))
+        self.assertTrue(result.flags["C_CONTIGUOUS"])
+        np.testing.assert_allclose(result, test_data.numpy())
+
+
+if __name__ == "__main__":
+    unittest.main()

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest black flake8 mypy pytype
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
absl-py==1.4.0
attrs==22.2.0
black==22.8.0
cachetools==4.2.4
certifi==2021.5.30
charset-normalizer==2.0.12
click==8.0.4
cycler==0.11.0
dataclasses==0.8
decorator==4.4.2
flake8==5.0.4
google-auth==2.22.0
google-auth-oauthlib==0.4.6
grpcio==1.48.2
idna==3.10
imageio==2.15.0
importlab==0.8.1
importlib-metadata==4.8.3
iniconfig==1.1.1
kiwisolver==1.3.1
libcst==0.4.1
Markdown==3.3.7
matplotlib==3.3.4
mccabe==0.7.0
-e git+https://github.com/Project-MONAI/MONAI.git@edeac8f994bc4ad18b4da936395c8b3bd8ee1edc#egg=monai
mypy==0.971
mypy-extensions==1.0.0
networkx==2.5.1
nibabel==3.2.2
ninja==1.11.1.1
numpy==1.19.5
oauthlib==3.2.2
packaging==21.3
pathspec==0.9.0
Pillow==8.4.0
platformdirs==2.4.0
pluggy==1.0.0
protobuf==3.19.6
py==1.11.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycodestyle==2.9.1
pyflakes==2.5.0
pyparsing==3.1.4
pytest==7.0.1
python-dateutil==2.9.0.post0
pytorch-ignite==0.3.0
pytype==2022.1.5
PyWavelets==1.1.1
PyYAML==6.0.1
requests==2.27.1
requests-oauthlib==2.0.0
rsa==4.9
scikit-image==0.17.2
scipy==1.5.4
six==1.17.0
tabulate==0.8.10
tensorboard==2.10.1
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tifffile==2020.9.3
toml==0.10.2
tomli==1.2.3
torch==1.10.2
typed-ast==1.5.5
typing-inspect==0.9.0
typing_extensions==4.1.1
urllib3==1.26.20
Werkzeug==2.0.3
zipp==3.6.0

name: MONAI
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - absl-py==1.4.0
      - attrs==22.2.0
      - black==22.8.0
      - cachetools==4.2.4
      - charset-normalizer==2.0.12
      - click==8.0.4
      - cycler==0.11.0
      - dataclasses==0.8
      - decorator==4.4.2
      - flake8==5.0.4
      - google-auth==2.22.0
      - google-auth-oauthlib==0.4.6
      - grpcio==1.48.2
      - idna==3.10
      - imageio==2.15.0
      - importlab==0.8.1
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - kiwisolver==1.3.1
      - libcst==0.4.1
      - markdown==3.3.7
      - matplotlib==3.3.4
      - mccabe==0.7.0
      - mypy==0.971
      - mypy-extensions==1.0.0
      - networkx==2.5.1
      - nibabel==3.2.2
      - ninja==1.11.1.1
      - numpy==1.19.5
      - oauthlib==3.2.2
      - packaging==21.3
      - pathspec==0.9.0
      - pillow==8.4.0
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - protobuf==3.19.6
      - py==1.11.0
      - pyasn1==0.5.1
      - pyasn1-modules==0.3.0
      - pycodestyle==2.9.1
      - pyflakes==2.5.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - python-dateutil==2.9.0.post0
      - pytorch-ignite==0.3.0
      - pytype==2022.1.5
      - pywavelets==1.1.1
      - pyyaml==6.0.1
      - requests==2.27.1
      - requests-oauthlib==2.0.0
      - rsa==4.9
      - scikit-image==0.17.2
      - scipy==1.5.4
      - six==1.17.0
      - tabulate==0.8.10
      - tensorboard==2.10.1
      - tensorboard-data-server==0.6.1
      - tensorboard-plugin-wit==1.8.1
      - tifffile==2020.9.3
      - toml==0.10.2
      - tomli==1.2.3
      - torch==1.10.2
      - typed-ast==1.5.5
      - typing-extensions==4.1.1
      - typing-inspect==0.9.0
      - urllib3==1.26.20
      - werkzeug==2.0.3
      - zipp==3.6.0
prefix: /opt/conda/envs/MONAI

tests/test_to_numpy.py::TestToNumpy::test_numpy_input tests/test_to_numpy.py::TestToNumpy::test_tensor_input tests/test_to_numpyd.py::TestToNumpyd::test_numpy_input tests/test_to_numpyd.py::TestToNumpyd::test_tensor_input
monai/transforms/utility/dictionary.py monai/transforms/utility/array.py docs/source/transforms.rst
monai/transforms/utility/dictionary.py monai/transforms/utility/array.py docs/source/transforms.rst