You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the YOLOv5 issues and found no similar bug report.
YOLOv5 Component
No response
Bug
When i add "CA" to v5-7.0, segment , i want add CA to .yaml backbone each C3 end, when i train , begin:
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 16 but got size 32 for tensor number 1 in the list.
Environment
Traceback (most recent call last):
File "D:/YOLO/yolov5-v7.0/models/yolo.py", line 377, in
model = Model(opt.cfg).to(device)
File "D:/YOLO/yolov5-v7.0/models/yolo.py", line 195, in init
m.stride = torch.tensor([s / x.shape[-2] for x in forward(torch.zeros(1, ch, s, s))]) # forward
File "D:/YOLO/yolov5-v7.0/models/yolo.py", line 194, in
forward = lambda x: self.forward(x)[0] if isinstance(m, Segment) else self.forward(x)
File "D:/YOLO/yolov5-v7.0/models/yolo.py", line 209, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "D:/YOLO/yolov5-v7.0/models/yolo.py", line 121, in _forward_once
x = m(x) # run
File "D:\Anaconda\envs\yolov5-7.0\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "D:\YOLO\yolov5-v7.0\models\common.py", line 313, in forward
return torch.cat(x, self.d)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 16 but got size 32 for tensor number 1 in the list.
Process finished with exit code 1
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
Yes I'd like to help by submitting a PR!
The text was updated successfully, but these errors were encountered:
Hello! It looks like you're encountering a tensor size mismatch error when trying to integrate CA (Channel Attention, I'm guessing?) into the YOLOv5 model. This often happens due to incompatible feature map sizes when concatenating or merging layers.
A common cause for this issue is when the dimensions of the feature maps don't align due to different strides, paddings, or kernel sizes upstream in your network modifications. Ensure the CA module you're integrating outputs a tensor that matches the expected dimensions for concatenating with the backbone's feature map at that point.
For example, if you're adding a CA module after a C3 block, double-check:
The output size of the C3 block.
The expected input size of the layer following your CA module.
Adjust the CA module accordingly to ensure the output size matches the expected input size of the subsequent layer.
Without specific details of your CA implementation, a generic suggestion would be to review and match the output dimensions of your CA module to the input requirements of the subsequent layers. This may involve adjusting kernel sizes, strides, or paddings in your CA module or adapting the merging strategy.
Keep exploring and tweaking — the YOLOv5 architecture is quite flexible, and custom enhancements like yours contribute to the community's growth! If you continue to experience issues, consider providing a snippet of how you're integrating CA into the model for more targeted advice. Good luck! 🚀
👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.
For additional resources and information, please see the links below:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLO 🚀 and Vision AI ⭐
Search before asking
YOLOv5 Component
No response
Bug
When i add "CA" to v5-7.0, segment , i want add CA to .yaml backbone each C3 end, when i train , begin:
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 16 but got size 32 for tensor number 1 in the list.
Environment
Traceback (most recent call last):
File "D:/YOLO/yolov5-v7.0/models/yolo.py", line 377, in
model = Model(opt.cfg).to(device)
File "D:/YOLO/yolov5-v7.0/models/yolo.py", line 195, in init
m.stride = torch.tensor([s / x.shape[-2] for x in forward(torch.zeros(1, ch, s, s))]) # forward
File "D:/YOLO/yolov5-v7.0/models/yolo.py", line 194, in
forward = lambda x: self.forward(x)[0] if isinstance(m, Segment) else self.forward(x)
File "D:/YOLO/yolov5-v7.0/models/yolo.py", line 209, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "D:/YOLO/yolov5-v7.0/models/yolo.py", line 121, in _forward_once
x = m(x) # run
File "D:\Anaconda\envs\yolov5-7.0\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "D:\YOLO\yolov5-v7.0\models\common.py", line 313, in forward
return torch.cat(x, self.d)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 16 but got size 32 for tensor number 1 in the list.
Process finished with exit code 1
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: