YOLOv7引入Swin Transformer以及CCNet出现的问题

YOLOv7引入Swin Transformer以及CCNet出现的问题
一、YOLOv7训练完,运行test.py的时候出现:RuntimeError: expected scalar type Float but found Half  错误
采用GPU训练时出现的问题!

解决方案:

将test.py中的 model.half()改成model.float()   同时  将 torch_utils.py中的 out = self.model(x) 改成 out = self.model(x.float())

如图:

改完之后,运行就可以了!!!

 

二、YOLOv7中使用Swin Transformer训练完,运行test.py的时候出现:RuntimeError: shape '[8, 6, 8, 10, 8, 32]' is invalid for input of size 1032192 错误。

解决方案:

这里是由于输入图片大小为 640 导致的问题,而设置672或者224不会出现这个问题,但设置 448 还是会出现这个问题。具体原因不太清楚。Window_size 设置的为 7 。

 

 

 

posted on 2023-03-28 21:00  DLst_liu  阅读(919)  评论(0编辑  收藏  举报