cqu20160901 / yolov8pose_onnx_tensorRT_rknn_horizon

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

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

Open jerryandjune opened 1 year ago

jerryandjune commented 1 year 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 1 year ago

是的

jerryandjune commented 1 year ago

好的,我试试,感谢