Solution: According to the error message, find common.py
AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from 'E:\\All_in\\新建文件夹\\yolo_double\\yolov5_stereo_Pro\\models\\common.py'>
Add the SPPF class above spp:
class SPPF(nn.Module):
def __init__(self, c1, c2, k=5):
super().__init__()
c_ = c1 // 2
self.cv1 = Conv(c1, c_, 1, 1)
self.cv2 = Conv(c_ * 4, c2, 1, 1)
self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2)
Afterwards warnings will be marked red, select and click to import 'warnings'
Continue to report an error:
RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton dimension 3
solution:
Download:
https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt
to replace the default downloaded yolov5s.pt, because the default download is
the replacement of V6.1, after running detect.py it's ok