photosynthesis-team / piq

Measures and metrics for image2image tasks. PyTorch.
Apache License 2.0
1.41k stars 120 forks source link

Implementation of `gradient_map` does not support >1 channels #332

Open zakajd opened 1 year ago

zakajd commented 1 year ago

Describe the bug According to documentation this function should work for images with arbitrary number of channels, but current implementation fails for C<> 1.

Also documentation says that expected kernel shape is [n, k, k] while in reality we always pass [n, 1, k, k]. [n, k, k] is actually not supported due to the same error in implementation

To Reproduce

x = torch.randn(4, 3, 16, 16)
kernels = torch.randn(2, 1, 3, 3) # should be torch.randn(2, 3, 3) 

output = gradient_map(x, kernels)

Expected behavior No errors, proper computation.

Additional context Not sure yet, but probably this function also doesn't support kN != 2. Will check while fixing UPD: Supports, but probably math for kN > 2 should be different. Won't dig into that now