BadourAlBahar / pose-with-style

[SIGGRAPH Asia 2021] Pose with Style: Detail-Preserving Pose-Guided Image Synthesis with Conditional StyleGAN
https://pose-with-style.github.io/
MIT License
268 stars 41 forks source link

Tensor dimension do not match for some target images #5

Closed manish-baghel closed 2 years ago

manish-baghel commented 2 years ago

@BadourAlBahar First of all thanks for the amazing work and congrats on the achievement.

A lot of times for specific target images tensor dimensions do not match for gamma and input/x at https://github.com/BadourAlBahar/pose-with-style/blob/51edbe6a177e2f38d8a277697852b646d2ddf6dc/model.py#L361

Please help if you have encountered a similar issue or if you have any guidance on how to fix it. Complete error log -

initialize network with normal
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:3635: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
  "See the documentation of nn.Upsample for details.".format(mode)
/content/PWS/op/conv2d_gradfix.py:89: UserWarning: conv2d_gradfix not supported on PyTorch 1.10.0+cu111. Falling back to torch.nn.functional.conv2d().
  f"conv2d_gradfix not supported on PyTorch {torch.__version__}. Falling back to torch.nn.functional.conv2d()."
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:4004: UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.
  "Default grid_sample and affine_grid behavior has changed "
Traceback (most recent call last):
  File "inference.py", line 144, in <module>
    generate(args, g_ema, device, mean_latent)
  File "inference.py", line 98, in generate
    output, _ = g_ema(appearance=appearance, pose=target_pose)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/content/PWS/model.py", line 851, in forward
    out = self.conv1(out, latent[0], noise=noise[0])
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/content/PWS/model.py", line 460, in forward
    out = self.conv(input, style)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/content/PWS/model.py", line 377, in forward
    input = self.modulate(input, gamma, beta)
  File "/content/PWS/model.py", line 361, in modulate
    return gamma * x + beta
RuntimeError: The size of tensor a (16) must match the size of tensor b (37) at non-singleton dimension 2

Thnx~!!

BadourAlBahar commented 2 years ago

This is probably due to a size issue. You can try and print out the size of appearance and target_pose. Both should be 512x512.

BadourAlBahar commented 2 years ago

Please verify the size. Feel free to reopen if the issue persists.