sefibk / KernelGAN

Other
337 stars 77 forks source link

Why the warning:UserWarning: a target size that is different to the input size ?? #41

Open zerodohero opened 4 years ago

zerodohero commented 4 years ago

Your work is admirable I have a small question, I use the real image to run this program, why will prompt the target size is not the same as the input size warning?But you can do everything.Is there an image size restriction on This application? This will likely lead to penresults due to broadcasting.

D:\sofe\anaconda\python.exe D:/docum/PycharmProjects/KernelGAN-master/train.py --SR --real WARNING:tensorflow:From D:\sofe\anaconda\lib\site-packages\tensorflow_core\python\compat\v2_compat.py:65: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version. Instructions for updating: non-resource variables are not supported in the long term output D:\docum\PycharmProjects\KernelGAN-master\results Scale Factor: X2 ZSSR: True Real Image: True


STARTED KernelGAN on: "./test_images\1004141-6h-A1 original.tif"... 0%| | 0/3000 [00:00<?, ?it/s]### D:\sofe\anaconda\lib\site-packages\torch\nn\modules\loss.py:88: UserWarning: Using a target size (torch.Size([13])) that is different to the input size (torch.Size([1, 1, 13, 13])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. return F.l1_loss(input, target, reduction=self.reduction) D:\sofe\anaconda\lib\site-packages\torch\nn\modules\loss.py:88: UserWarning: Using a target size (torch.Size([])) that is different to the input size (torch.Size([1])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. return F.l1_loss(input, target, reduction=self.reduction) D:\sofe\anaconda\lib\site-packages\torch\nn\modules\loss.py:431: UserWarning: Using a target size (torch.Size([2])) that is different to the input size (torch.Size([2, 1])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. return F.mse_loss(input, target, reduction=self.reduction) 100%|██████████████████▉| 2999/3000 [04:19<00:00, 12.19it/s]out test_images\1004141-6h-A1 original KernelGAN estimation complete!

sefibk commented 4 years ago
  1. Thanks for the compliments.
  2. IDK why you get these messages. Please verify your environment is exactly as specified in the requirements.txt.
  3. I didn't try the network on huge images, but on realistic sized ones (few MegaPixels) - it works.. On the other hand, very small images (200x200 pixels) would not work very well. If you are interested in such images, I can elaborate.
zerodohero commented 4 years ago
  1. Thanks for the compliments.
  2. IDK why you get these messages. Please verify your environment is exactly as specified in the requirements.txt.
  3. I didn't try the network on huge images, but on realistic sized ones (few MegaPixels) - it works.. On the other hand, very small images (200x200 pixels) would not work very well. If you are interested in such images, I can elaborate.

Thank you for your prompt reply My operating environment is indeed different from the requirement. Is this just related to the environment?Does this warning affect the outcome? The images I currently test are really around 200200, but most of the images I will run next time are above 70007000, so the program will be very easy to rebuild, right?

sefibk commented 4 years ago

I am not familiar with these warnings but I suspect the environment. 7000x7000 is larger than I experimented on - I hope it works well... It should!

zerodohero commented 4 years ago

I am not familiar with these warnings but I suspect the environment. 7000x7000 is larger than I experimented on - I hope it works well... It should!

ok,Thank you for your reply

victorca25 commented 3 years ago

Hello. I (and probably everyone using a recent pytorch version) also get the warnings. These happen on three of the losses: BoundariesLoss, SumOfWeightsLoss and CentralizedLoss. Two of them are easy to fix, as they only need to add the missing dimension, but BoundariesLoss compares a fully expanded kernel (torch.Size([1, 1, 13, 13])) to the self.zero_label Variable, which only has one dimension of size 'k_size'. If expanded to the correct size, (1 x 1 x k_size x k_size) the warning goes away.

sefibk commented 3 years ago

What torch version are you using?

victorca25 commented 3 years ago

Pytorch 1.3.0 and 1.6.0, tested on both.

sefibk commented 3 years ago

I specified in the requirements torch=1.0.0. Try that version, I do not want to change the code without understanding the degradation

victorca25 commented 3 years ago

Understandable. Just want to note that even with the warnings and no changes, it also works perfectly, so it's more of a minor inconvenience than a problem.