Closed Nora-Go closed 4 months ago
Hi @Nora-Go, The easiest workaround is probably installing the filter layer from the MONAI repo: https://docs.monai.io/en/stable/networks.html#trainablebilateralfilter
Their pre-compiled library is less sensitive to different Cuda/PyTorch versions. We contributed the trainable bilateral filter for better usability and platform support.
Let me know if that worked for your cluster. If not, I can provide my running configuration. Note that the layer input layout is slightly modified in the MONAI layer to adapt MONAI conventions.
Hope that helped!
Hi,
I fear it is not working for me: AttributeError: module 'monai.networks.layers' has no attribute 'TrainableBilateralFilter' ImportError: cannot import name 'TrainableBilateralFilter' from 'monai.networks.layers'
I have monai version 1.1.0 installed. Should I open an issue at monai's?
I just checked, the layers were first part of release 1.2.0 (https://github.com/Project-MONAI/MONAI/releases/tag/1.2.0). So, upgrading MONAI should do the job :)
Ah! :D I used a virtual environment with python 3.7 so pip installed version 1.1.0. With python 3.9 it installed version 1.2.0. The problem with installing is now solved! Thank you @faebstn96 !
However, I have a problem with dimensions: It seems that the layer does not take batches and the channel dimension? But only single images? At least the check in line 247 "ValueError(f"Spatial dimension ({len_input}) must match initialized len(spatial_sigma).")" does not make sense to me. Should I make a new issue? And here or at monai? :)
Did you consider the slightly changed layer input specification for the MONAI layer? There, the initial spatial sigmas are input as a vector with two or three entries depending on how many dimensions your filtered image has. This is due to adapting MONAI conventions.
The check just makes sure that the number of provided spatial sigmas matches the number of spatial input dimensions.
Currently, batch dimensions >1 are supported. However, the channel dimension is restricted to a single channel due to open questions on the handling/mixing of multiple image channels.
Hope that helped :)
I input the spatial_sigmas as tuple with two entries, as I have 2D images.
I raised an issue at MONAI's GitHub: https://github.com/Project-MONAI/MONAI/issues/7457 (which seems to be a duplicate of https://github.com/Project-MONAI/MONAI/issues/7444)
The error arises at the check (line 246 in filtering.py):
if self.len_spatial_sigma != len_input: raise ValueError(f"Spatial dimension ({len_input}) must match initialized len(spatial_sigma).")
len_input is 4, as I have a batch, and a channel dimension and 2D images.
self.len_spatial_sigma is 2, as I input 2 spatial_sigmas.
I already tried simply commenting the check out - but then I get issues with the C++ extensions: https://github.com/Project-MONAI/MONAI/issues/7464 This problem is probably nothing you can help me with, but it makes me unable to use MONAI at the moment. Still, if you have any idea how to proceed (either with MONAI or your Git), I'd be very glad to hear it!
Thanks a lot for your help! It is much appreciated!
@Nora-Go Did you manage to get the C++ extension installation working?
@lucasdevries No :) I don't use MONAI now. I made it work by installing this package here on the cluster. My problem was that I was trying to install it on a node that did not have a GPU. So solution was to go onto a node that has a GPU, allocate the GPU and then install ist. Hope this helps!
Hi :) and moin!
I fear I face a problem installing your package on a cluster (locally it works fine). I create a venv with a python version (tried 3.7, 3.8, 3.9, 3.10, 3.11), make cuda available (tried 11.3.1, 11.6.2, 11.7.1, 12.1.1) and install torch (tried 1.13.0+cu116, 2.2.0+cu118). Then I tried pip install bilateralfilter_torch (I also tried it via the setup.py).
The error I get is:
Trying it with --use-pep517 leads to:
I'm stuck on both errors, as all possible solutions would require sudo rights (which I don't have) as far as I see it.
Could you help me with that? Already telling me the versions you used, might help me :)