pytorch-msssim icon indicating copy to clipboard operation
pytorch-msssim copied to clipboard

Best way to deal with small images with msssim

Open stevenewbold opened this issue 4 years ago • 4 comments

I have a network that trains 64x64px images. I can't currently use MSSSIM as a loss function as the number of downsamples means I need a larger input image size as suggested by the error message,

Image size should be larger than 160 due to the 4 downsamplings in ms-ssim

What is the best way to deal with this? I have to keep the 64x64px input image size for various reasons. My immediate thoughts are to pad the input images with zero (or 0.5???) up to 160x160 prior to calculating the loss?

Is this a legitimate way to go?

Steve

stevenewbold avatar May 24 '21 16:05 stevenewbold

An other alternative with the options I have available would be to reduce the window size to a value of three, but I assume this would make the function pretty much ineffective?

stevenewbold avatar May 24 '21 16:05 stevenewbold

Hi @stevenewbold , maybe you can resize your images to fit the resolution requirement.

VainF avatar May 24 '21 16:05 VainF

Hi @stevenewbold , maybe you can resize your images to fit the resolution requirement.

Unfortunately I can't as the model runs as part of plugin where inference happens on number of image tiles that are predetermined by other processes.

I'm testing to see if padding the inputs with black produces a valid result and comparing with SSID.

Edit - actually perhaps you mean resizing prior to calculating loss only? I'm trying that with resize() now to see if it works better as using padding of black isn't giving decent results.

stevenewbold avatar May 24 '21 17:05 stevenewbold

It is better to try and use a smaller Gaussian kernel for the image.

Also, padding is not advised since it results in you calculating the metric in undefined areas. Resizing is also not really advised since you are interpolating data meaning you calculate your loss in another space than the original image space.

danieltudosiu avatar May 25 '21 15:05 danieltudosiu