Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lazy.utils.resample output dtype #6340

Closed
wyli opened this issue Apr 12, 2023 · 1 comment · Fixed by #6341, #6343, #6344 or #6251
Closed

lazy.utils.resample output dtype #6340

wyli opened this issue Apr 12, 2023 · 1 comment · Fixed by #6341, #6343, #6344 or #6251
Assignees
Labels
bug Something isn't working

Comments

@wyli
Copy link
Contributor

wyli commented Apr 12, 2023

Describe the bug
the output of grid resampling is always float32

with resampler.trace_transform(False): # don't track this transform in `img`
return resampler(img=img, **call_kwargs)

out = _maybe_new_metatensor(img, dtype=torch.float32)

the crop pad 'resampling' should also output float32

img = monai.transforms.crop_or_pad_nd(img, matrix_np, out_spatial_size, mode=call_kwargs["padding_mode"])
img.affine = call_kwargs["dst_affine"]
return img

otherwise collating random transforms of different data types can run into exceptions.

cc @dongyang0122

@wyli wyli self-assigned this Apr 12, 2023
@wyli wyli added the bug Something isn't working label Apr 12, 2023
wyli added a commit that referenced this issue Apr 12, 2023
Fixes #6340
Fixes #6253 

### Description


### 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).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Wenqi Li <[email protected]>
@wyli wyli mentioned this issue Apr 12, 2023
7 tasks
wyli added a commit that referenced this issue Apr 12, 2023
closes #6339 (closes #6337)
closes #6341 (closes #6340 closes #6253)


### 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).
- [x] 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: binliu <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
Co-authored-by: binliunls <[email protected]>
@wyli wyli closed this as completed in 6b7b1e7 Apr 12, 2023
@wyli
Copy link
Contributor Author

wyli commented Apr 14, 2023

this is still an issue for the early returning cases

img.affine = call_kwargs["dst_affine"]
return img

@wyli wyli reopened this Apr 14, 2023
wyli added a commit to myron/MONAI that referenced this issue Apr 14, 2023
Signed-off-by: Wenqi Li <[email protected]>
wyli added a commit that referenced this issue Apr 14, 2023
SlidingWindowInfererAdapt extends SlidingWindowInferer to automatically
switch to buffered and then to CPU stitching, when OOM on GPU. It also
records a size of such large images to automatically try CPU stitching
for the next large image of a similar size. If the stitching 'device'
input parameter is provided,
automatic adaptation won't be attempted, please keep the default option
device = None for adaptive behavior.
Note: the output might be on CPU (even if the input was on GPU), if the
GPU memory was not sufficient.

---
also fixes #6340 by adding one line to the resampling

---------

Signed-off-by: myron <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
Co-authored-by: Wenqi Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant