问题1:
data = self.stream.read(size)
UnicodeDecodeError: 'gbk' codec can't decode byte 0x84 in position 189: illegal multibyte sequence
解决:
项目代码中train.py中,64行加'rb',如下图一样:models文件夹下yolo.py文件74行,加‘rb';
问题2:
AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from 'C:\\Users\\gpu\\Desktop\\yolov5-v5.0\\models\\common.py'>
解决:
找到models文件夹下common.py文件;
在149行SPP类下面162行位置添加SPPF类:
SPPF类代码如下:
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)
def forward(self, x):
x = self.cv1(x)
with warnings.catch_warnings():
warnings.simplefilter('ignore')
y1 = self.m(x)
y2 = self.m(y1)
return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))