Open timleslie opened 1 year ago
@timleslie thanks to raise this issue. The raised error comes directly from Pytorch which doesn't handle this corner case and since we just map grid_sample
, I don't think we should over engineer their functionality. /cc @johnnv1 @ducha-aiki
To understand better, what's you use cases for C=0 and what it represents ?
Hi @edgarriba, thanks for taking a look at this!
We're working on a computer vision model, and the C
in our (B, C, H, W)
tensor represents the number of different positive findings in a batch of data. In general the data distribution is such that each batch contains at least one positive finding, but we can't guarantee that, and we occasionally hit the edge case of no positive samples in our batch, at which point this particular transform fails.
Our full transform includes RandomHorizontalFlip
, RandomVerticalFlip
as well, both of which handle the C=0
case as expected.
I see -- tensors with a zero dimension has an empty data storage, i believe in your case you should skip that batch.
>>> torch.rand(1,1,1,0).storage().nbytes() == 0
True
Describe the bug
kornia.augmentation.RandomAffine
doesn't handle the degenerate case of aC=0
tensor.Reproduction steps
Expected behavior
I would expect the transform to succeed, with an output of the same shape as the input.
Environment
Collecting environment information... PyTorch version: 1.13.1 Is debug build: False CUDA used to build PyTorch: None ROCM used to build PyTorch: N/A
OS: macOS 13.1 (x86_64) GCC version: Could not collect Clang version: 14.0.0 (clang-1400.0.29.202) CMake version: Could not collect Libc version: N/A
Python version: 3.8.16 (default, Dec 16 2022, 11:04:25) [Clang 14.0.0 (clang-1400.0.29.202)] (64-bit runtime) Python platform: macOS-13.1-x86_64-i386-64bit Is CUDA available: False CUDA runtime version: No CUDA CUDA_MODULE_LOADING set to: N/A GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True
CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Versions of relevant libraries: [pip3] efficientnet-pytorch==0.7.1 [pip3] mypy==1.1.1 [pip3] mypy-extensions==1.0.0 [pip3] numpy==1.23.5 [pip3] pytorch-lightning==1.8.6 [pip3] segmentation-models-pytorch==0.3.2 [pip3] torch==1.13.1 [pip3] torchmetrics==0.11.4 [pip3] torchvision==0.14.1 [conda] Could not collect