cqu20160901 / yolov8pose_onnx_tensorRT_rknn_horizon

yolov8pose 部署版本,便于移植不同平台(onnx、tensorRT、rknn、Horizon)。
35 stars 1 forks source link

请教一下,在那个位置修改SiLU为ReLU? #2

Open jerryandjune opened 10 months ago

jerryandjune commented 10 months ago

class Conv(nn.Module): """Standard convolution with args(ch_in, ch_out, kernel, stride, padding, groups, dilation, activation).""" default_act = nn.SiLU() # -------------------------是这里吗?---------------------------

def __init__(self, c1, c2, k=1, s=1, p=None, g=1, d=1, act=True):
    """Initialize Conv layer with given arguments including activation."""
    super().__init__()
    self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p, d), groups=g, dilation=d, bias=False)
    self.bn = nn.BatchNorm2d(c2)
    self.act = self.default_act if act is True else act if isinstance(act, nn.Module) else nn.Identity()

def forward(self, x):
    """Apply convolution, batch normalization and activation to input tensor."""
    return self.act(self.bn(self.conv(x)))

def forward_fuse(self, x):
    """Perform transposed convolution of 2D data."""
    return self.act(self.conv(x))

class ConvTranspose(nn.Module): """Convolution transpose 2d layer.""" default_act = nn.SiLU() #-------------------------是这里吗?---------------------------

def __init__(self, c1, c2, k=2, s=2, p=0, bn=True, act=True):
    """Initialize ConvTranspose2d layer with batch normalization and activation function."""
    super().__init__()
    self.conv_transpose = nn.ConvTranspose2d(c1, c2, k, s, p, bias=not bn)
    self.bn = nn.BatchNorm2d(c2) if bn else nn.Identity()
    self.act = self.default_act if act is True else act if isinstance(act, nn.Module) else nn.Identity()

def forward(self, x):
    """Applies transposed convolutions, batch normalization and activation to input."""
    return self.act(self.bn(self.conv_transpose(x)))

def forward_fuse(self, x):
    """Applies activation and convolution transpose operation to input."""
    return self.act(self.conv_transpose(x))

请教一下,是上面的位置吗?谢谢

cqu20160901 commented 10 months ago

是的

jerryandjune commented 10 months ago

好的,我试试,感谢