alexandrosstergiou / SoftPool

[ICCV 2021] Code for approximated exponential maximum pooling
MIT License
288 stars 52 forks source link

about result picture #51

Closed zhangxue2115 closed 2 years ago

zhangxue2115 commented 2 years ago

I want to get a result picture after softpooling to compare with other method,how can I do ?

alexandrosstergiou commented 2 years ago

Hi @zhangxue2115 ,

You can convert your images to a pytorch tensor and then use the corresponding soft_pool2d() function

zhangxue2115 commented 2 years ago

I am very happy to receive your reply, but I still have some questions. After my picture is converted into a pytorch tensor, torch Size =([3, 1080, 1920]), when I use soft_ Pool2d, it will report a mistake atx = F.avg_pool2d(x.mul(e_x), kernel_size, stride=stride).mul_(sum(kernel_size)).div_(F.avg_pool2d(e_x, kernel_size, stride=stride).mul_(sum(kernel_size))),showing"Given` input size: (3x1x1920). Calculated output size: (3x-4x956). Output size is too small" where is my error? I cant find it...

alexandrosstergiou commented 2 years ago

As the error states, your tensor is of size 3x1x1920, so you should check the size of the tensor that you are using as an argument. Also, you should include a batch dimension. This works fine for example:

import torch
import softpool_cuda
from SoftPool import soft_pool2d

tmp = torch.rand(1,3,1080,1920)
s1 = soft_pool2d(tmp)
# s1.shape is [1, 3, 540, 960]
zhangxue2115 commented 2 years ago

Your reply is very helpful to me.Thank you for your patience.