def __init__(self, num_refinement_stages=1, num_channels=128, num_heatmaps=17, mode='bilinear'): super().__init__() self.model = nn.Sequential( conv(3, 32, stride=2, bias=False), conv_dw(32, 64), conv_dw(64, 128, stride=2), conv_dw(128, 128), conv_dw(128, 256, stride=2), conv_dw(256, 256), conv_dw(256, 512), # conv4_2 conv_dw(512, 512, dilation=2, padding=2), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512), # conv5_5 ) self.cpm = nn.Sequential( conv(512, 256), conv(256, 128), ) self.initial_stage = InitialStage(num_channels, num_heatmaps) self.refinement_stages = nn.ModuleList() for idx in range(num_refinement_stages): self.refinement_stages.append( RefinementStage(num_channels + num_heatmaps, num_channels, num_heatmaps, mode))
def __init__(self, in_channels, out_channels, num_heatmaps, num_pafs): super().__init__() self.trunk = nn.Sequential( RefinementStageBlock(in_channels, out_channels), RefinementStageBlock(out_channels, out_channels), RefinementStageBlock(out_channels, out_channels), RefinementStageBlock(out_channels, out_channels), RefinementStageBlock(out_channels, out_channels)) self.heatmaps = nn.Sequential( conv(out_channels, out_channels, kernel_size=1, padding=0, bn=False), conv(out_channels, num_heatmaps, kernel_size=1, padding=0, bn=False, relu=False)) self.pafs = nn.Sequential( conv(out_channels, out_channels, kernel_size=1, padding=0, bn=False), conv(out_channels, num_pafs, kernel_size=1, padding=0, bn=False, relu=False))
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 __init__(self, in_channels, out_channels, num_heatmaps, num_pafs): super().__init__() self.trunk = nn.Sequential( #----------------------------------------------------In OpenPose five 7 * 7, RefinementStageBlock( in_channels, out_channels ), #---------------------------here replaced with five time [3*3 , 3*3 , 1*1] RefinementStageBlock(out_channels, out_channels), RefinementStageBlock(out_channels, out_channels), RefinementStageBlock(out_channels, out_channels), RefinementStageBlock(out_channels, out_channels)) self.heatmaps = nn.Sequential( conv(out_channels, out_channels, kernel_size=1, padding=0, bn=False), conv(out_channels, num_heatmaps, kernel_size=1, padding=0, bn=False, relu=False)) self.pafs = nn.Sequential( conv(out_channels, out_channels, kernel_size=1, padding=0, bn=False), conv(out_channels, num_pafs, kernel_size=1, padding=0, bn=False, relu=False))
def __init__(self, in_channels, out_channels, num_heatmaps, mode='bilinear'): super().__init__() self.trunk = nn.Sequential( UShapedContextBlock(in_channels, mode), RefinementStageBlock(in_channels, out_channels), RefinementStageBlock(out_channels, out_channels), RefinementStageBlock(out_channels, out_channels), ) self.heatmaps = nn.Sequential( conv(out_channels, out_channels, kernel_size=1, padding=0, bn=False), conv(out_channels, num_heatmaps, kernel_size=1, padding=0, bn=False, relu=False))
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 __init__(self, in_channels, out_channels):#--------512,128 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), #kernel_size=3, padding=1, stride=1, dilation=1 conv_dw_no_bn(out_channels, out_channels), #kernel_size=3, padding=1, stride=1, dilation=1 conv_dw_no_bn(out_channels, out_channels) #kernel_size=3, padding=1, stride=1, dilation=1 ) self.conv = conv(out_channels, out_channels, bn=False)
def __init__(self, in_channels, out_channels, ratio, should_align=False): super().__init__() self.should_align = should_align self.bottleneck = nn.Sequential( conv(in_channels, in_channels // ratio, kernel_size=1, padding=0), conv(in_channels // ratio, in_channels // ratio), conv(in_channels // ratio, out_channels, kernel_size=1, padding=0) ) if self.should_align: self.align = conv(in_channels, out_channels, kernel_size=1, padding=0)
def __init__(self, in_channels, mid_channels, out_channels): super().__init__() self.trunk = nn.Sequential( RefinementStageBlock(in_channels, mid_channels), RefinementStageBlock(mid_channels, mid_channels) ) self.feature_maps = nn.Sequential( conv(mid_channels, mid_channels, kernel_size=1, padding=0, bn=False), conv(mid_channels, out_channels, kernel_size=1, padding=0, bn=False, relu=False) )
def __init__(self, in_channels, cfg): super().__init__() self.align = conv(in_channels, int(cfg[0]), kernel_size=1, padding=0, bn=False) # self.select = Selection(cfg[0]) self.trunk = nn.Sequential(conv_dw_no_bn(int(cfg[0]), int(cfg[2])), conv_dw_no_bn(int(cfg[2]), int(cfg[4])), conv_dw_no_bn(int(cfg[4]), int(cfg[6]))) self.conv = conv(int(cfg[6]), int(cfg[7]), bn=False)
def __init__(self, num_channels, num_heatmaps): super().__init__() self.trunk = nn.Sequential(conv(num_channels, num_channels), conv(num_channels, num_channels), conv(num_channels, num_channels)) self.heatmaps = nn.Sequential( conv(num_channels, 512, kernel_size=1, padding=0, bn=False), conv(512, num_heatmaps, kernel_size=1, padding=0, bn=False, relu=False))
def __init__(self, num_refinement_stages=1, num_channels=128, num_heatmaps=1 + num_keys, num_pafs=2 * len(BODY_PARTS_PAF_IDS)): super().__init__() self.model = nn.Sequential( conv(3, 32, stride=2, bias=False), conv_dw(32, 64), conv_dw(64, 128, stride=2), conv_dw(128, 128), conv_dw(128, 256, stride=2), conv_dw(256, 256), conv_dw(256, 512), # conv4_2 conv_dw(512, 512, dilation=2, padding=2), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512) # conv5_5 ) self.cpm = Cpm(512, num_channels) self.initial_stage = InitialStage(num_channels, num_heatmaps, num_pafs) self.refinement_stages = nn.ModuleList() for idx in range(num_refinement_stages): self.refinement_stages.append( RefinementStage(num_channels + num_heatmaps + num_pafs, num_channels, num_heatmaps, num_pafs))
def __init__(self, num_refinement_stages=1, num_channels=128, num_heatmaps=19, num_pafs=38):#--------------why 38 super().__init__() self.model = nn.Sequential(#---------------------------------------------------MobileNet-----------------------------------first conv( 3, 32, stride=2, bias=False), conv_dw( 32, 64),#---------------------------------------------dw means depthwise convolution conv_dw( 64, 128, stride=2), conv_dw(128, 128), conv_dw(128, 256, stride=2), conv_dw(256, 256), conv_dw(256, 512), # Stride of this conv4_2 removed from MobileNetv1 to preserve the receptive field. conv4_2 means kernel 4 * 4, padding 2 conv_dw(512, 512, dilation=2, padding=2), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512) # conv5_5 The last layer used from MobileNet is this one. ) self.cpm = Cpm(512, num_channels)#-------------------------------------------------What is this CPM?--------------second self.initial_stage = InitialStage(num_channels, num_heatmaps, num_pafs)#--------------------------------------------third self.refinement_stages = nn.ModuleList()#------------------------------------------------------------------------fourth for idx in range(num_refinement_stages): self.refinement_stages.append(RefinementStage(num_channels + num_heatmaps + num_pafs, num_channels, num_heatmaps, num_pafs))
def __init__(self, num_refinement_stages=1, num_channels=128, num_heatmaps=19, num_pafs=38, is_convertible_by_mo=False): super().__init__() self.is_convertible_by_mo = is_convertible_by_mo self.model = nn.Sequential( conv( 3, 32, stride=2, bias=False), conv_dw( 32, 64), conv_dw( 64, 128, stride=2), conv_dw(128, 128), conv_dw(128, 256, stride=2), conv_dw(256, 256), conv_dw(256, 512), # conv4_2 conv_dw(512, 512, dilation=2, padding=2), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512) # conv5_5 ) self.cpm = Cpm(512, num_channels) self.initial_stage = InitialStage(num_channels, num_heatmaps, num_pafs) self.refinement_stages = nn.ModuleList() for idx in range(num_refinement_stages): self.refinement_stages.append(RefinementStage(num_channels + num_heatmaps + num_pafs, num_channels, num_heatmaps, num_pafs)) self.Pose3D = Pose3D(128, num_2d_heatmaps=57) if self.is_convertible_by_mo: self.fake_conv_heatmaps = nn.Conv2d(num_heatmaps, num_heatmaps, kernel_size=1, bias=False) self.fake_conv_heatmaps.weight = nn.Parameter(torch.zeros(num_heatmaps, num_heatmaps, 1, 1)) self.fake_conv_pafs = nn.Conv2d(num_pafs, num_pafs, kernel_size=1, bias=False) self.fake_conv_pafs.weight = nn.Parameter(torch.zeros(num_pafs, num_pafs, 1, 1))
def __init__(self, in_channels): super().__init__() self.encoder1 = nn.Sequential( conv(in_channels, in_channels * 2, stride=2), conv(in_channels * 2, in_channels * 2), ) self.encoder2 = nn.Sequential( conv(in_channels * 2, in_channels * 2, stride=2), conv(in_channels * 2, in_channels * 2), ) self.decoder2 = nn.Sequential( conv(in_channels * 2 + in_channels * 2, in_channels * 2), conv(in_channels * 2, in_channels * 2), ) self.decoder1 = nn.Sequential(conv(in_channels * 3, in_channels * 2), conv(in_channels * 2, in_channels))
def __init__(self, in_channels, mode='bilinear'): super().__init__() self.mode_interpolation = mode self.encoder1 = nn.Sequential( conv(in_channels, in_channels * 2, stride=2), conv(in_channels * 2, in_channels * 2), ) self.encoder2 = nn.Sequential( conv(in_channels * 2, in_channels * 2, stride=2), conv(in_channels * 2, in_channels * 2), ) self.decoder2 = nn.Sequential( conv(in_channels * 2 + in_channels * 2, in_channels * 2), conv(in_channels * 2, in_channels * 2), ) self.decoder1 = nn.Sequential(conv(in_channels * 3, in_channels * 2), conv(in_channels * 2, in_channels))
def __init__(self, num_refinement_stages=1, num_channels=128, num_heatmaps=19, num_pafs=38): super().__init__() self.ghost0 = conv(3, 32, stride=2, bias=False) self.ghost1 = conv(3, 32, stride=2, bias=False) self.ghost2 = conv(3, 32, stride=2, bias=False) self.phase0 = conv_dw(32, 64) # self.phase1 = nn.Sequential( # conv_dw(32, 64), # ) self.model = nn.Sequential( conv_dw(64, 128, stride=2), conv_dw(128, 128), conv_dw(128, 256, stride=2), conv_dw(256, 256), conv_dw(256, 512), # conv4_2 conv_dw(512, 512, dilation=2, padding=2), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512) # conv5_5 ) self.cpm = Cpm(512, num_channels) self.initial_stage = InitialStage(num_channels, num_heatmaps, num_pafs) self.refinement_stages = nn.ModuleList() for idx in range(num_refinement_stages): self.refinement_stages.append( RefinementStage(num_channels + num_heatmaps + num_pafs, num_channels, num_heatmaps, num_pafs))
def __init__(self, num_refinement_stages=1, num_channels=128, num_heatmaps=19, num_pafs=38): super().__init__() self.model = nn.Sequential( conv( 3, 32, stride=2, bias=False), conv_dw( 32, 64), conv_dw( 64, 128, stride=2), conv_dw(128, 128), conv_dw(128, 256, stride=2), conv_dw(256, 256), conv_dw(256, 512), # conv4_2 conv_dw(512, 512, dilation=2, padding=2), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512) # conv5_5 ) self.cpm = Cpm(512, num_channels) self.initial_stage = InitialStage(num_channels, num_heatmaps, num_pafs)
def __init__(self, num_channels, num_heatmaps, num_pafs): super().__init__() self.trunk = nn.Sequential( conv(num_channels, num_channels, bn=False), conv(num_channels, num_channels, bn=False), #conv(num_channels, num_channels, bn=False)#-----------------------------------remove one convolution layer ) self.heatmaps = nn.Sequential( conv(num_channels, 512, kernel_size=1, padding=0, bn=False), conv(512, num_heatmaps, kernel_size=1, padding=0, bn=False, relu=False) ) self.pafs = nn.Sequential( conv(num_channels, 512, kernel_size=1, padding=0, bn=False), conv(512, num_pafs, kernel_size=1, padding=0, bn=False, relu=False) )
def __init__(self, cfg, num_refinement_stages=1, num_channels=128, num_heatmaps=15, num_pafs=26): super().__init__() layers = [] layers += [conv(3, int(cfg[0][0]), stride=2, bias=False)] for i in range(int((len(cfg[0]) - 1) / 2)): if (i == 1 or i == 3): layers += [ conv_dw(int(cfg[0][i * 2]), int(cfg[0][i * 2 + 2]), stride=2) ] elif (i == 6): layers += [ conv_dw(int(cfg[0][i * 2]), int(cfg[0][i * 2 + 2]), dilation=2, padding=2) ] else: layers += [conv_dw(int(cfg[0][i * 2]), int(cfg[0][i * 2 + 2]))] self.model = nn.Sequential(*layers) self.cpm = Cpm_new(int(cfg[0][-1]), cfg[1]) self.initial_stage = InitialStage_new(int(cfg[1][-1]), num_channels, num_heatmaps, num_pafs) self.refinement_stages = nn.ModuleList() for idx in range(num_refinement_stages): self.refinement_stages.append( RefinementStage( int(cfg[1][-1]) + num_heatmaps + num_pafs, num_channels, num_heatmaps, num_pafs))
def __init__(self, num_channels, num_heatmaps, num_pafs): super().__init__() self.trunk = nn.Sequential( #----------------------------------------Original OPENPOSE contained two copies of these conv() layers, for PAF and HMs conv( num_channels, num_channels, bn=False ), #--------------------Here just 1 in the original lightweight openpose conv(num_channels, num_channels, bn=False), conv(num_channels, num_channels, bn=False)) #--------------------------------------------------------------------Then, give the op to both paf and HM branches self.heatmaps = nn.Sequential( conv(num_channels, 512, kernel_size=1, padding=0, bn=False), conv(512, num_heatmaps, kernel_size=1, padding=0, bn=False, relu=False)) self.pafs = nn.Sequential( conv(num_channels, 512, kernel_size=1, padding=0, bn=False), conv(512, num_pafs, kernel_size=1, padding=0, bn=False, relu=False))