-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
MONAI transforms can't only support Tensor
backend
#2933
Comments
Hi @rijobro , I will try to enhance them ASAP before 0.7 release if you have no concerns. Thanks in advance. |
Hi, all of the transforms that I have been updating will perform any necessary numpy<->torch conversions. Do you mean that the updated transforms might now return the data in a different format (e.g., torch instead of numpy) and some of the old transforms can't handle that? |
Hi @rijobro , Yes, that's the problem, old transforms can't handle the Thanks. |
I've tried to make it so that for random transforms, I've tried to perform the data conversion that would have been applied if the transform had have been applied. If I've missed that anywhere, please let me know and I'll update. (example of conversion when transform is not applied here). |
Thanks @rijobro , I already fixed this kind issue in Thanks. |
Just to clarify, my understanding is that the backend is about how the computation is implemented, using numpy or torch API. For now it's fine to have numpy-only or torch-only backend. But at the moment for #2231 we should ensure all the transforms support these input-output types:
|
My vision is that, if necessary, each transform will convert to the correct image type. That is to say, if the computation requires However, it seems that since we're currently part-way through the changes, some transforms will be in chains that would have originally received numpy input, but now they're getting torch tensors instead. I suppose as a temporary fix, we could modify all problematic transforms to have something like this at the start of the def __call__(img):
img, *_ = convert_data_type(img, np.ndarray)
... |
Hi @rijobro , Yes, that's exactly what I planed to do for this ticket. Thanks. |
Great. However, this change was something I was trying to avoid (converting back to original type). Rather than converting back at the end of the transform, all other transforms should be able to handle torch and numpy input. |
Hi @rijobro , I agree with your point, maybe when we added Tensor support to all the existing transforms, we can refactor the output logic. Thanks. |
Ok, sounds reasonable. |
Is your feature request related to a problem? Please describe.
Currently, some transforms only support Tensor backend, which will break previous numpy based transform chains.
Need to update them to make sure all the transforms support both
numpy
andTensor
backends or onlynumpy
backend.The text was updated successfully, but these errors were encountered: