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

RuntimeError: The size of tensor a (3) must match the size of tensor b (9) at non-singleton dimension 0 #6

Closed
studiumcirclus opened this issue Dec 3, 2023 · 1 comment

Comments

@studiumcirclus
Copy link

All of my images are 256x256 pixels (taken from images sample folder, just some of the 256x256 ones)

C:\git\image-captioning>python inference.py -i C:\git\image-captioning\inputs --batch 3 --gpu 0
Device: cpu
Images found: 8
Split size: 2
Checkpoint loading...
load checkpoint from ./checkpoints/model_large_caption.pth

Model to cpu
Inference started
0batch [00:02, ?batch/s]
Traceback (most recent call last):
File "C:\git\image-captioning\inference.py", line 88, in
caption = model.generate(
File "C:\git\image-captioning\models\blip.py", line 201, in generate
outputs = self.text_decoder.generate(
File "C:\Python\Python310\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\Python\Python310\lib\site-packages\transformers\generation\utils.py", line 1752, in generate
return self.beam_search(
File "C:\Python\Python310\lib\site-packages\transformers\generation\utils.py", line 3091, in beam_search
outputs = self(
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "C:\git\image-captioning\models\med.py", line 886, in forward
outputs = self.bert(
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "C:\git\image-captioning\models\med.py", line 781, in forward
encoder_outputs = self.encoder(
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "C:\git\image-captioning\models\med.py", line 445, in forward
layer_outputs = layer_module(
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "C:\git\image-captioning\models\med.py", line 361, in forward
cross_attention_outputs = self.crossattention(
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "C:\git\image-captioning\models\med.py", line 277, in forward
self_outputs = self.self(
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "C:\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "C:\git\image-captioning\models\med.py", line 178, in forward
attention_scores = torch.matmul(query_layer, key_layer.transpose(-1, -2))
RuntimeError: The size of tensor a (3) must match the size of tensor b (9) at non-singleton dimension 0

@cobanov
Copy link
Owner

cobanov commented Dec 14, 2023

same with #5

@cobanov cobanov closed this as completed Dec 14, 2023
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