Skip to content

Commit cda1209

Browse files
authored
Merge branch 'dev' into 8267-fix-normalize-intensity
2 parents 3c58135 + 56d1f62 commit cda1209

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

monai/networks/nets/swin_unetr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,9 +782,9 @@ def forward(self, x):
782782
x1 = x[:, 1::2, 0::2, 0::2, :]
783783
x2 = x[:, 0::2, 1::2, 0::2, :]
784784
x3 = x[:, 0::2, 0::2, 1::2, :]
785-
x4 = x[:, 1::2, 0::2, 1::2, :]
786-
x5 = x[:, 0::2, 1::2, 0::2, :]
787-
x6 = x[:, 0::2, 0::2, 1::2, :]
785+
x4 = x[:, 1::2, 1::2, 0::2, :]
786+
x5 = x[:, 1::2, 0::2, 1::2, :]
787+
x6 = x[:, 0::2, 1::2, 1::2, :]
788788
x7 = x[:, 1::2, 1::2, 1::2, :]
789789
x = torch.cat([x0, x1, x2, x3, x4, x5, x6, x7], -1)
790790
x = self.norm(x)

tests/test_load_image.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@ def test_nibabel_reader(self, input_param, filenames, expected_shape):
217217
@SkipIfNoModule("kvikio")
218218
@parameterized.expand([TEST_CASE_GPU_1, TEST_CASE_GPU_2, TEST_CASE_GPU_3, TEST_CASE_GPU_4])
219219
def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape):
220-
test_image = np.random.rand(128, 128, 128)
220+
if torch.__version__.endswith("nv24.8"):
221+
# related issue: https://github.com/Project-MONAI/MONAI/issues/8274
222+
# for this version, use randint test case to avoid the issue
223+
test_image = torch.randint(0, 256, (128, 128, 128), dtype=torch.uint8).numpy()
224+
else:
225+
test_image = np.random.rand(128, 128, 128)
221226
with tempfile.TemporaryDirectory() as tempdir:
222227
for i, name in enumerate(filenames):
223228
filenames[i] = os.path.join(tempdir, name)

tests/test_zarr_avg_merger.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@
1919
from torch.nn.functional import pad
2020

2121
from monai.inferers import ZarrAvgMerger
22-
from monai.utils import optional_import
22+
from monai.utils import get_package_version, optional_import, version_geq
2323
from tests.utils import assert_allclose
2424

2525
np.seterr(divide="ignore", invalid="ignore")
2626
zarr, has_zarr = optional_import("zarr")
27+
if has_zarr:
28+
if version_geq(get_package_version("zarr"), "3.0.0"):
29+
directory_store = zarr.storage.LocalStore("test.zarr")
30+
else:
31+
directory_store = zarr.storage.DirectoryStore("test.zarr")
32+
else:
33+
directory_store = None
2734
numcodecs, has_numcodecs = optional_import("numcodecs")
2835

2936
TENSOR_4x4 = torch.randint(low=0, high=255, size=(2, 3, 4, 4), dtype=torch.float32)
@@ -154,7 +161,7 @@
154161

155162
# explicit directory store
156163
TEST_CASE_10_DIRECTORY_STORE = [
157-
dict(merged_shape=TENSOR_4x4.shape, store=zarr.storage.DirectoryStore("test.zarr")),
164+
dict(merged_shape=TENSOR_4x4.shape, store=directory_store),
158165
[
159166
(TENSOR_4x4[..., :2, :2], (0, 0)),
160167
(TENSOR_4x4[..., :2, 2:], (0, 2)),

0 commit comments

Comments
 (0)