Project Code

class RefinementStageBlock(nn.Module):
    def __init__(self, in_channels, out_channels):
        super().__init__()
        self.initial = conv(in_channels, out_channels, kernel_size=1, padding=0, bn=False)
        self.trunk = nn.Sequential(
            conv(out_channels, out_channels),
            conv(out_channels, out_channels, dilation=2, padding=2)
        )

    def forward(self, x):
        initial_features = self.initial(x)
        trunk_features = self.trunk(initial_features)
        return initial_features + trunk_features

The RefinementStageBlock class is a PyTorch module that serves as a building block for the refinement stages in the pose estimation model. It processes input feature maps and refines them using a combination of standard and dilated convolutions, with a residual connection to preserve input information.


Class Definition

class RefinementStageBlock(nn.Module):
    def __init__(self, in_channels, out_channels):
        super().__init__()

Components

  1. self.initial

    self.initial = conv(in_channels, out_channels, kernel_size=1, padding=0, bn=False)
    
  2. self.trunk

    self.trunk = nn.Sequential(
        conv(out_channels, out_channels),
        conv(out_channels, out_channels, dilation=2, padding=2)
    )
    

Forward Method

def forward(self, x):
    initial_features = self.initial(x)
    trunk_features = self.trunk(initial_features)
    return initial_features + trunk_features

Purpose in the Model