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

--size parameters must be a power of 2 #3

Open
hackerfriendly opened this issue Dec 28, 2021 · 2 comments
Open

--size parameters must be a power of 2 #3

hackerfriendly opened this issue Dec 28, 2021 · 2 comments

Comments

@hackerfriendly
Copy link

First, thank you for your effort! I've enjoyed experimenting with this code and I've learned a lot from your contributions.

Sorry I'm not much help here, but I noticed that specifying an x or y that isn't a power of 2 raises a RuntimeError. Not sure if that's intended behavior at this stage:

RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 24 but got size 25 for tensor number 1 in the list.

Full traceback follows.

$ ./clip_sample.py --size 640 400 "something"
Traceback (most recent call last):
File "./clip_sample.py", line 203, in
main()
File "./clip_sample.py", line 197, in main
run_all(args.n, args.batch_size)
File "./clip_sample.py", line 192, in run_all
outs = run(x[i:i+cur_batch_size], steps, clip_embed[i:i+cur_batch_size])
File "./clip_sample.py", line 180, in run
return sampling.cond_sample(model, x, steps, args.eta, extra_args, cond_fn_)
File "/work/env/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "/work/v-diffusion-pytorch/diffusion/sampling.py", line 62, in cond_sample
v = model(x, ts * steps[i], **extra_args)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/v-diffusion-pytorch/diffusion/models/cc12m_1.py", line 246, in forward
out = self.net(torch.cat([input, timestep_embed], dim=1))
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/v-diffusion-pytorch/diffusion/models/cc12m_1.py", line 63, in forward
return torch.cat([self.main(input), self.skip(input)], dim=1)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/v-diffusion-pytorch/diffusion/models/cc12m_1.py", line 63, in forward
return torch.cat([self.main(input), self.skip(input)], dim=1)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/v-diffusion-pytorch/diffusion/models/cc12m_1.py", line 63, in forward
return torch.cat([self.main(input), self.skip(input)], dim=1)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/v-diffusion-pytorch/diffusion/models/cc12m_1.py", line 63, in forward
return torch.cat([self.main(input), self.skip(input)], dim=1)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/work/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/work/v-diffusion-pytorch/diffusion/models/cc12m_1.py", line 63, in forward
return torch.cat([self.main(input), self.skip(input)], dim=1)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 24 but got size 25 for tensor number 1 in the list.

@crowsonkb
Copy link
Owner

At some point I am going to work out what the size parameters have to be divisible by and add it to the model class for each model, because I am going to have to do this for upscaler models because they have no set native resolution...

@lopho
Copy link

lopho commented Jan 6, 2022

From experimentation I determined the sides have to be divisible by 64.

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

3 participants