Skip to content

Commit

Permalink
Fix test load image issue (#8297)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
yiheng-wang-nv authored Jan 14, 2025
1 parent 1c00ea2 commit eaa901c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion 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 Down

0 comments on commit eaa901c

Please sign in to comment.