YOLOV5学习笔记(十)——GradCAM热力图可视化
https://blog.csdn.net/HUASHUDEYANJING/article/details/127654972
1.YOLOV5中导入from utils.datasets import letterbox出现问题
ModuleNotFoundError: No module named 'utils.datasets'
解决:letterbox在dataloaders.py文件中,最后我改成了from utils.dataloaders import letterbox
2.YOLOV5GradCAM热力图可视化用自己的权重时出现报错:RuntimeError: The size of tensor a (32) must match the size of tensor b (512) at non-singleton dimension 1
解决:问题在于你训练模型的batchsize大小和官方推荐大小的比例,想正常跑通就补0补到一样的size
因为我们自己训练时batch-size的变小了,导致weights的维度也降低了,把weights位置为1维度上升torch.cat()升维到512
3.AttributeError: 'Detect' object has no attribute 'onnx_dynamic'
解决:改为dynamic