Project Code

class Cpm(nn.Module):
    def __init__(self, in_channels, out_channels):
        super().__init__()
        self.align = conv(in_channels, out_channels, kernel_size=1, padding=0, bn=False)
        self.trunk = nn.Sequential(
            conv_dw_no_bn(out_channels, out_channels),
            conv_dw_no_bn(out_channels, out_channels),
            conv_dw_no_bn(out_channels, out_channels)
        )
        self.conv = conv(out_channels, out_channels, bn=False)

    def forward(self, x):
        x = self.align(x)
        x = self.conv(x + self.trunk(x))
        return x

The Cpm class (short for Convolutional Pose Machine) is a PyTorch module designed to process feature maps and refine them for pose estimation tasks. Here's a detailed breakdown of its components and functionality:


Class Definition

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


Components

  1. self.align

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

    self.trunk = nn.Sequential(
        conv_dw_no_bn(out_channels, out_channels),
        conv_dw_no_bn(out_channels, out_channels),
        conv_dw_no_bn(out_channels, out_channels)
    )
    
  3. self.conv

    self.conv = conv(out_channels, out_channels, bn=False)
    

Forward Method

def forward(self, x):
    x = self.align(x)
    x = self.conv(x + self.trunk(x))
    return x

Purpose in the Model