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

The size of tensor a (145) must match the size of tensor b (150) at non-singleton dimension 3 #470

Open
bluusun opened this issue Feb 8, 2024 · 1 comment
Labels
bug Something isn't working planned

Comments

@bluusun
Copy link

bluusun commented Feb 8, 2024

Loading model /root/.cache/huggingface/hub/models--lllyasviel--control_v11f1e_sd15_tile/snapshots/3f877705c37010b7221c3d10743307d6b5b6efac/diffusion_pytorch_model.bin onto cuda backend...

  0%|          | 0/40 [00:00<?, ?it/s]

Traceback (most recent call last):
File "/usr/local/bin/imagine", line 7, in
imaginairy.cli.imagine.imagine_cmd()
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/usr/local/lib/python3.10/site-packages/imaginairy/cli/imagine.py", line 187, in imagine_cmd
return _imagine_cmd(
File "/usr/local/lib/python3.10/site-packages/imaginairy/cli/shared.py", line 220, in _imagine_cmd
filenames = imagine_image_files(
File "/usr/local/lib/python3.10/site-packages/imaginairy/api/generate.py", line 90, in imagine_image_files
for result in imagine(
File "/usr/local/lib/python3.10/site-packages/imaginairy/api/generate.py", line 237, in imagine
result = generate_single_image(
File "/usr/local/lib/python3.10/site-packages/imaginairy/api/generate_refiners.py", line 336, in generate_single_image
x = sd(
File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/imaginairy/vendored/refiners/foundationals/latent_diffusion/model.py", line 94, in forward
unconditional_prediction, conditional_prediction = self.unet(latents).chunk(2)
File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/imaginairy/vendored/refiners/fluxion/layers/chain.py", line 279, in forward
result = self._call_layer(layer, name, *intermediate_args)
File "/usr/local/lib/python3.10/site-packages/imaginairy/vendored/refiners/fluxion/layers/chain.py", line 273, in _call_layer
raise ChainError(message) from None
imaginairy.vendored.refiners.fluxion.layers.chain.ChainError:

RuntimeError:
The size of tensor a (145) must match the size of tensor b (150) at non-singleton dimension 3

(CHAIN)
├── Conv2d(in_channels=4, out_channels=320, kernel_size=(3, 3), padding=(1, 1))
├── >>> (RES) Residual() | SD1ControlnetAdapter.SD1ControlnetAdapter.SD1UNet.Controlnet_1.DownBlocks.Chain_1.Residual
│ ├── UseContext(context=controlnet, key=condition_details)
│ └── (CHAIN) ConditionEncoder()
│ ├── (CHAIN) #1 ...
│ ├── (CHAIN) #2 ...
│ ├── (CHAIN) #3 ...
│ ├── (CHAIN) #4 ...
│ └── Conv2d(in_channels=256, out_channels=320, kernel_size=(3, 3), padding=(1, 1))
└── (PASS)
0: Tensor(shape=(2, 320, 99, 150), dtype=float16, device=cuda:0, min=-4.19, max=3.85, mean=0.01, std=0.40, norm=1238.00, grad=False)

(CHAIN) DownBlocks(in_channels=4)
├── >>> (CHAIN) | SD1ControlnetAdapter.SD1ControlnetAdapter.SD1UNet.Controlnet_1.DownBlocks.Chain_1 #1
│ ├── Conv2d(in_channels=4, out_channels=320, kernel_size=(3, 3), padding=(1, 1))
│ ├── (RES) Residual()
│ │ ├── UseContext(context=controlnet, key=condition_details)
│ │ └── (CHAIN) ConditionEncoder() ...
│ └── (PASS)
│ ├── Conv2d(in_channels=320, out_channels=320, kernel_size=(1, 1))
│ └── Lambda(_store_residual(x: torch.Tensor))
├── (CHAIN) (x2) #2
│ ├── (SUM) ResidualBlock(in_channels=320, out_channels=320)
0: Tensor(shape=(2, 4, 99, 150), dtype=float16, device=cuda:0, min=-4.61, max=4.02, mean=-0.18, std=1.12, norm=389.50, grad=False)

(PASS) Controlnet(name=details)
├── (PASS) TimestepEncoder()
│ ├── UseContext(context=diffusion, key=timestep)
│ ├── (CHAIN) RangeEncoder(sinuosidal_embedding_dim=320, embedding_dim=1280)
│ │ ├── Lambda(compute_sinuosoidal_embedding(x: jaxtyping.Int[Tensor, '*batch 1']) -> jaxtyping.Float[Tensor, '*batch 1 embedding_dim'])
│ │ ├── Converter(set_device=False)
│ │ ├── Linear(in_features=320, out_features=1280) #1
│ │ ├── SiLU()
│ │ └── Linear(in_features=1280, out_features=1280) #2
│ └── SetContext(context=range_adapter, key=timestep_embedding_details)
├── Slicing(dim=1, end=4)
0: Tensor(shape=(2, 4, 99, 150), dtype=float16, device=cuda:0, min=-4.61, max=4.02, mean=-0.18, std=1.12, norm=389.50, grad=False)

(CHAIN) SD1UNet(in_channels=4)
├── >>> (PASS) Controlnet(name=details) | SD1ControlnetAdapter.SD1ControlnetAdapter.SD1UNet.Controlnet_1 #1
│ ├── (PASS) TimestepEncoder()
│ │ ├── UseContext(context=diffusion, key=timestep)
│ │ ├── (CHAIN) RangeEncoder(sinuosidal_embedding_dim=320, embedding_dim=1280) ...
│ │ └── SetContext(context=range_adapter, key=timestep_embedding_details)
│ ├── Slicing(dim=1, end=4)
│ ├── (CHAIN) DownBlocks(in_channels=4)
│ │ ├── (CHAIN) #1 ...
│ │ ├── (CHAIN) (x2) #2 ...
│ │ ├── (CHAIN) #3 ...
0: Tensor(shape=(2, 4, 99, 150), dtype=float16, device=cuda:0, min=-4.61, max=4.02, mean=-0.18, std=1.12, norm=389.50, grad=False)

@bluusun
Copy link
Author

bluusun commented Feb 8, 2024

This seems to be related to --size 720p / --size 1080p. It seems the older specification with separate width/height did not have that limitation.

Now when using a control image smaller than the specified image the error occurs.

Leaving out sizes works (but images are much smaller)

@brycedrennan brycedrennan added the bug Something isn't working label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working planned
Projects
None yet
Development

No branches or pull requests

2 participants