yolov8 face 错误修改

derronqi/yolov8-face: yolov8 face detection with landmark (github.com)

 

问题:训练yolov8-lite-s,yolov8-lite-t的时候会出错,Cannot use yolov8-lite-s · Issue #3 · derronqi/yolov8-face (github.com)

TypeError: conv2d() received an invalid combination of arguments - got (Tensor, Parameter, Parameter, tuple, tuple, tuple, int), but expected one of:
 * (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, tuple of ints padding, tuple of ints dilation, int groups)
      didn't match because some of the arguments have invalid types: (Tensor, Parameter, Parameter, tuple of (int, int), tuple of (int, int), tuple of (bool, bool), int)
 * (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, str padding, tuple of ints dilation, int groups)
      didn't match because some of the arguments have invalid types: (Tensor, Parameter, Parameter, tuple of (int, int), tuple of (int, int), tuple of (bool, bool), int)

原因:conv参数没有匹配上,如下:

 

改源码"ultralytics\nn\modules\block.py",line 42

class StemBlock(nn.Module):
    def __init__(self, c1, c2, k=3, s=2, p=None, g=1,d=1, act=True):
        super(StemBlock, self).__init__()
        self.stem_1 = Conv(c1, c2, k, s, p, g, d, act)
        self.stem_2a = Conv(c2, c2 // 2, 1, 1, 0)
        self.stem_2b = Conv(c2 // 2, c2, 3, 2, 1)
        self.stem_2p = nn.MaxPool2d(kernel_size=2,stride=2,ceil_mode=True)
        self.stem_3 = Conv(c2 * 2, c2, 1, 1, 0)

解决。

posted on 2024-08-07 12:01  WenJXUST  阅读(165)  评论(0)    收藏  举报