MONAI icon indicating copy to clipboard operation
MONAI copied to clipboard

TrainableBilateralFilter seems to not work with batch and channel dimensions (Duplicate of #7444)

Open Nora-Go opened this issue 1 year ago • 0 comments

First of all thank you for your nice work!!!

My issue is that the TrainableBilateralFilter does not seem to work with batch and channel dimensions.

In the init function of my model:

self.bilateral_filter = TrainableBilateralFilter(spatial_sigma=(0.5, 0.5), color_sigma=0.4)

In the forward pass of my model:

print("x.shape:{}".format(x.shape))
x = self.bilateral_filter(x)

The output is:

x.shape:torch.Size([2, 1, 224, 224])
[...]
ValueError: Spatial dimension (4) must match initialized len(spatial_sigma).

I did expect the layer to work with two initial dimensions, as is stated in the documentation: "Can run on 1D, 2D, or 3D tensors (on top of Batch and Channel dimensions)." If I'm using it the wrong way, I would be quite happy if you can point me towards my error.

python -c "import monai; monai.config.print_debug_info()"


================================
Printing MONAI config...
================================
MONAI version: 1.2.0
Numpy version: 1.22.4
Pytorch version: 1.13.0+cu116
MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False
MONAI rev id: c33f1ba588ee00229a309000e888f9817b4f1934
MONAI __file__: C:\Users\nora_admin\anaconda3\envs\Denoised_HookFormer_CRF\lib\site-packages\monai\__init__.py

Optional dependencies:
Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.
ITK version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: NOT INSTALLED or UNKNOWN VERSION.
scikit-image version: 0.19.1
Pillow version: 10.2.0
Tensorboard version: NOT INSTALLED or UNKNOWN VERSION.
gdown version: NOT INSTALLED or UNKNOWN VERSION.
TorchVision version: 0.14.0+cu116
tqdm version: 4.66.1
lmdb version: NOT INSTALLED or UNKNOWN VERSION.
psutil version: NOT INSTALLED or UNKNOWN VERSION.
pandas version: NOT INSTALLED or UNKNOWN VERSION.
einops version: 0.6.0
transformers version: NOT INSTALLED or UNKNOWN VERSION.
mlflow version: NOT INSTALLED or UNKNOWN VERSION.
pynrrd version: NOT INSTALLED or UNKNOWN VERSION.

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies


================================
Printing system config...
================================
`psutil` required for `print_system_info`

================================
Printing GPU config...
================================
Num GPUs: 1
Has CUDA: True
CUDA version: 11.6
cuDNN enabled: True
cuDNN version: 8302
Current device: 0
Library compiled for CUDA architectures: ['sm_37', 'sm_50', 'sm_60', 'sm_61', 'sm_70', 'sm_75', 'sm_80', 'sm_86', 'compute_37']
GPU 0 Name: NVIDIA GeForce RTX 2080 Ti
GPU 0 Is integrated: False
GPU 0 Is multi GPU board: False
GPU 0 Multi processor count: 68
GPU 0 Total memory (GB): 11.0
GPU 0 CUDA capability (maj.min): 7.5

Nora-Go avatar Feb 09 '24 10:02 Nora-Go