Skip to content

Commit eaa901c

Browse files
Fix test load image issue (#8297)
Fixes #8274 . ### Description The new test has already tested with the same 24.08 + A100 env. I did some tests but cannot reproduce the original test case error (there are NaN values or significant small/large data). Since only 24.08 base image has the issue (24.10 does not have), I decided to use a different test case for 24.08 and prepared this PR ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Yiheng Wang <vennw@nvidia.com>
1 parent 1c00ea2 commit eaa901c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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)

0 commit comments

Comments
 (0)