Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into fix-zarr
Browse files Browse the repository at this point in the history
  • Loading branch information
KumoLiu committed Jan 14, 2025
2 parents b49ce64 + eaa901c commit 2630fbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions monai/networks/nets/swin_unetr.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,9 @@ def forward(self, x):
x1 = x[:, 1::2, 0::2, 0::2, :]
x2 = x[:, 0::2, 1::2, 0::2, :]
x3 = x[:, 0::2, 0::2, 1::2, :]
x4 = x[:, 1::2, 0::2, 1::2, :]
x5 = x[:, 0::2, 1::2, 0::2, :]
x6 = x[:, 0::2, 0::2, 1::2, :]
x4 = x[:, 1::2, 1::2, 0::2, :]
x5 = x[:, 1::2, 0::2, 1::2, :]
x6 = x[:, 0::2, 1::2, 1::2, :]
x7 = x[:, 1::2, 1::2, 1::2, :]
x = torch.cat([x0, x1, x2, x3, x4, x5, x6, x7], -1)
x = self.norm(x)
Expand Down
9 changes: 7 additions & 2 deletions tests/test_load_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ def test_nibabel_reader(self, input_param, filenames, expected_shape):
@SkipIfNoModule("kvikio")
@parameterized.expand([TEST_CASE_GPU_1, TEST_CASE_GPU_2, TEST_CASE_GPU_3, TEST_CASE_GPU_4])
def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape):
test_image = np.random.rand(128, 128, 128)
if torch.__version__.endswith("nv24.8"):
# related issue: https://github.com/Project-MONAI/MONAI/issues/8274
# for this version, use randint test case to avoid the issue
test_image = torch.randint(0, 256, (128, 128, 128), dtype=torch.uint8).numpy()
else:
test_image = np.random.rand(128, 128, 128)
with tempfile.TemporaryDirectory() as tempdir:
for i, name in enumerate(filenames):
filenames[i] = os.path.join(tempdir, name)
Expand All @@ -233,7 +238,7 @@ def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape):
input_param_cpu = input_param.copy()
input_param_cpu["to_gpu"] = False
result_cpu = LoadImage(image_only=True, **input_param_cpu)(filenames)
self.assertTrue(torch.allclose(result_cpu, result.cpu(), atol=1e-6))
assert_allclose(result_cpu, result.cpu(), atol=1e-6)

@parameterized.expand([TEST_CASE_6, TEST_CASE_7, TEST_CASE_8, TEST_CASE_8_1, TEST_CASE_9])
def test_itk_reader(self, input_param, filenames, expected_shape):
Expand Down

0 comments on commit 2630fbf

Please sign in to comment.