运行yolov5中detect.py报错 RuntimeError: shape ‘[1, 3, 6, 80, 80]‘ is invalid for input of size 819200

运行yolov5中detect.py文件,报错 RuntimeError: shape ‘[1, 3, 6, 80, 80]’ is invalid for input of size 819200

运行:

python detect.py

报错如下:

RuntimeError: shape ‘[1, 3, 6, 80, 80]’ is invalid for input of size 819200

解决如下:

def forward(self, x):
        # x = x.copy()  # for profiling
        z = []  # inference output
        self.training |= self.export
        for i in range(self.nl):
            #[1, 128, 80, 80]
            bs, _, ny, nx = x[i].shape  # x(bs,255,20,20) to x(bs,3,20,20,85)
            x[i] =self.m[i](x[i]) # **增加这行代码**
            x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()

增加这行代码x[i] =self.m[i](x[i]),即可跑起来

你可能感兴趣的:(yolo,目标检测,python,pytorch,深度学习)