Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensor dimension do not match for some target images #5

Closed
manish-baghel opened this issue Feb 19, 2022 · 2 comments
Closed

Tensor dimension do not match for some target images #5

manish-baghel opened this issue Feb 19, 2022 · 2 comments

Comments

@manish-baghel
Copy link

manish-baghel commented Feb 19, 2022

@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

return gamma * x + beta

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
Copy link
Owner

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants