monai-weekly 1.5.dev2512__py3-none-any.whl → 1.5.dev2513__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- monai/__init__.py +1 -1
- monai/_version.py +3 -3
- monai/metrics/meandice.py +132 -76
- monai/networks/blocks/__init__.py +2 -1
- monai/networks/blocks/cablock.py +182 -0
- monai/networks/blocks/downsample.py +241 -2
- monai/networks/nets/restormer.py +337 -0
- monai/networks/utils.py +44 -1
- monai/utils/__init__.py +1 -0
- monai/utils/enums.py +13 -0
- {monai_weekly-1.5.dev2512.dist-info → monai_weekly-1.5.dev2513.dist-info}/METADATA +1 -1
- {monai_weekly-1.5.dev2512.dist-info → monai_weekly-1.5.dev2513.dist-info}/RECORD +20 -15
- {monai_weekly-1.5.dev2512.dist-info → monai_weekly-1.5.dev2513.dist-info}/WHEEL +1 -1
- tests/metrics/test_compute_meandice.py +3 -3
- tests/networks/blocks/test_CABlock.py +150 -0
- tests/networks/blocks/test_downsample_block.py +184 -0
- tests/networks/nets/test_restormer.py +147 -0
- tests/networks/utils/test_pixelunshuffle.py +51 -0
- tests/integration/test_downsample_block.py +0 -50
- {monai_weekly-1.5.dev2512.dist-info → monai_weekly-1.5.dev2513.dist-info}/licenses/LICENSE +0 -0
- {monai_weekly-1.5.dev2512.dist-info → monai_weekly-1.5.dev2513.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
# Copyright (c) MONAI Consortium
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
# Unless required by applicable law or agreed to in writing, software
|
7
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
8
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
9
|
+
# See the License for the specific language governing permissions and
|
10
|
+
# limitations under the License.
|
11
|
+
|
12
|
+
from __future__ import annotations
|
13
|
+
|
14
|
+
import unittest
|
15
|
+
|
16
|
+
import torch
|
17
|
+
|
18
|
+
from monai.networks.utils import pixelshuffle, pixelunshuffle
|
19
|
+
|
20
|
+
|
21
|
+
class TestPixelUnshuffle(unittest.TestCase):
|
22
|
+
|
23
|
+
def test_2d_basic(self):
|
24
|
+
x = torch.randn(2, 4, 16, 16)
|
25
|
+
out = pixelunshuffle(x, spatial_dims=2, scale_factor=2)
|
26
|
+
self.assertEqual(out.shape, (2, 16, 8, 8))
|
27
|
+
|
28
|
+
def test_3d_basic(self):
|
29
|
+
x = torch.randn(2, 4, 16, 16, 16)
|
30
|
+
out = pixelunshuffle(x, spatial_dims=3, scale_factor=2)
|
31
|
+
self.assertEqual(out.shape, (2, 32, 8, 8, 8))
|
32
|
+
|
33
|
+
def test_non_square_input(self):
|
34
|
+
x = torch.arange(192).reshape(1, 2, 12, 8)
|
35
|
+
out = pixelunshuffle(x, spatial_dims=2, scale_factor=2)
|
36
|
+
torch.testing.assert_close(out, torch.pixel_unshuffle(x, 2))
|
37
|
+
|
38
|
+
def test_different_scale_factor(self):
|
39
|
+
x = torch.arange(360).reshape(1, 2, 12, 15)
|
40
|
+
out = pixelunshuffle(x, spatial_dims=2, scale_factor=3)
|
41
|
+
torch.testing.assert_close(out, torch.pixel_unshuffle(x, 3))
|
42
|
+
|
43
|
+
def test_inverse_operation(self):
|
44
|
+
x = torch.arange(4096).reshape(1, 8, 8, 8, 8)
|
45
|
+
shuffled = pixelshuffle(x, spatial_dims=3, scale_factor=2)
|
46
|
+
unshuffled = pixelunshuffle(shuffled, spatial_dims=3, scale_factor=2)
|
47
|
+
torch.testing.assert_close(x, unshuffled)
|
48
|
+
|
49
|
+
|
50
|
+
if __name__ == "__main__":
|
51
|
+
unittest.main()
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# Copyright (c) MONAI Consortium
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
-
# you may not use this file except in compliance with the License.
|
4
|
-
# You may obtain a copy of the License at
|
5
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
-
# Unless required by applicable law or agreed to in writing, software
|
7
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
8
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
9
|
-
# See the License for the specific language governing permissions and
|
10
|
-
# limitations under the License.
|
11
|
-
|
12
|
-
from __future__ import annotations
|
13
|
-
|
14
|
-
import unittest
|
15
|
-
|
16
|
-
import torch
|
17
|
-
from parameterized import parameterized
|
18
|
-
|
19
|
-
from monai.networks import eval_mode
|
20
|
-
from monai.networks.blocks import MaxAvgPool
|
21
|
-
|
22
|
-
TEST_CASES = [
|
23
|
-
[{"spatial_dims": 2, "kernel_size": 2}, (7, 4, 64, 48), (7, 8, 32, 24)], # 4-channel 2D, batch 7
|
24
|
-
[{"spatial_dims": 1, "kernel_size": 4}, (16, 4, 63), (16, 8, 15)], # 4-channel 1D, batch 16
|
25
|
-
[{"spatial_dims": 1, "kernel_size": 4, "padding": 1}, (16, 4, 63), (16, 8, 16)], # 4-channel 1D, batch 16
|
26
|
-
[ # 4-channel 3D, batch 16
|
27
|
-
{"spatial_dims": 3, "kernel_size": 3, "ceil_mode": True},
|
28
|
-
(16, 4, 32, 24, 48),
|
29
|
-
(16, 8, 11, 8, 16),
|
30
|
-
],
|
31
|
-
[ # 1-channel 3D, batch 16
|
32
|
-
{"spatial_dims": 3, "kernel_size": 3, "ceil_mode": False},
|
33
|
-
(16, 1, 32, 24, 48),
|
34
|
-
(16, 2, 10, 8, 16),
|
35
|
-
],
|
36
|
-
]
|
37
|
-
|
38
|
-
|
39
|
-
class TestMaxAvgPool(unittest.TestCase):
|
40
|
-
|
41
|
-
@parameterized.expand(TEST_CASES)
|
42
|
-
def test_shape(self, input_param, input_shape, expected_shape):
|
43
|
-
net = MaxAvgPool(**input_param)
|
44
|
-
with eval_mode(net):
|
45
|
-
result = net(torch.randn(input_shape))
|
46
|
-
self.assertEqual(result.shape, expected_shape)
|
47
|
-
|
48
|
-
|
49
|
-
if __name__ == "__main__":
|
50
|
-
unittest.main()
|
File without changes
|
File without changes
|