コード例 #1
0
    def __init__(self, image_dim, num_joints):
        super(JORNet_light, self).__init__()

        in_features = ceil(image_dim * 0.125)**2 * 256
        self.num_joints = num_joints  # hand and object
        self.out_poses1 = cudafy(
            nn.Linear(in_features=in_features, out_features=1000),
            self.use_cuda)
        self.out_poses2 = cudafy(
            nn.Linear(in_features=1000, out_features=self.num_joints),
            self.use_cuda)
コード例 #2
0
ファイル: JORNet_light.py プロジェクト: pauloabelha/handy
    def __init__(self, params_dict):
        super(JORNet_light, self).__init__(params_dict)

        if params_dict['hand_only']:
            self.num_joints = 60  # hand
        else:
            self.num_joints = 66  # hand and object
        self.out_poses1 = cudafy(
            nn.Linear(in_features=160000, out_features=1000), self.use_cuda)
        self.out_poses2 = cudafy(
            nn.Linear(in_features=1000, out_features=self.num_joints),
            self.use_cuda)
コード例 #3
0
ファイル: JORNet_light.py プロジェクト: pauloabelha/handy
 def map_out_conv(self, in_channels):
     return cudafy(
         hand_detection_net.HALNetConvBlock(kernel_size=3,
                                            stride=1,
                                            filters=21,
                                            in_channels=in_channels,
                                            padding=1), self.use_cuda)
コード例 #4
0
    def __init__(self, dims, num_joints=20):
        super(JORNet, self).__init__()

        res3out, res4out, conv4e, conv4f, h, w = dims_fun(dims[0], dims[1])
        #         self.innerprod1_size = 256 * h * w
        self.crop_res = dims
        self.num_joints = num_joints
        #         self.main_loss_conv = cudafy(HALNet.HALNetConvBlock(
        #                 kernel_size=3, stride=1, filters=21, in_channels=256, padding=1),
        #             self.use_cuda)
        self.main_loss_deconv1 = cudafy(
            nn.Upsample(size=self.crop_res, mode='bilinear'), self.use_cuda)
        #self.main_loss_deconv2 = cudafy(nn.Upsample(scale_factor=1, mode='bilinear'),
        #                                self.use_cuda)
        if self.cross_entropy:
            self.softmax_final = cudafy(HALNet.SoftmaxLogProbability2D(),
                                        self.use_cuda)
        self.innerproduct1_joint1 = cudafy(
            nn.Linear(in_features=res3out, out_features=200), self.use_cuda)
        self.innerproduct2_joint1 = cudafy(
            nn.Linear(in_features=200, out_features=self.num_joints * 3),
            self.use_cuda)

        self.innerproduct1_joint2 = cudafy(
            nn.Linear(in_features=res4out, out_features=200), self.use_cuda)
        self.innerproduct2_joint2 = cudafy(
            nn.Linear(in_features=200, out_features=self.num_joints * 3),
            self.use_cuda)

        self.innerproduct1_joint3 = cudafy(
            nn.Linear(in_features=conv4e, out_features=200), self.use_cuda)
        self.innerproduct2_joint3 = cudafy(
            nn.Linear(in_features=200, out_features=self.num_joints * 3),
            self.use_cuda)

        self.innerproduct1_joint_main = cudafy(
            nn.Linear(in_features=conv4f, out_features=200), self.use_cuda)
        self.innerproduct2_join_main = cudafy(
            nn.Linear(in_features=200, out_features=self.num_joints * 3),
            self.use_cuda)
コード例 #5
0
ファイル: JORNet_light.py プロジェクト: pauloabelha/handy
 def map_out_to_loss(self, innerprod1_size):
     return cudafy(nn.Linear(in_features=innerprod1_size, out_features=200),
                   self.use_cuda)
コード例 #6
0
 def __init__(self, params_dict):
     super(HALNet, self).__init__()
     # initialize variables
     self.joint_ixs = parse_model_param(params_dict,
                                        'joint_ixs',
                                        default_value="Mandatory")
     self.use_cuda = parse_model_param(params_dict,
                                       'use_cuda',
                                       default_value=False)
     self.num_joints = len(self.joint_ixs)
     self.num_channels = params_dict['num_channels']
     self.cross_entropy = parse_model_param(params_dict,
                                            'cross_entropy',
                                            default_value=True)
     # build network
     self.conv1 = cudafy(
         HALNetConvBlock(kernel_size=7,
                         stride=1,
                         filters=64,
                         in_channels=self.num_channels,
                         padding=3), self.use_cuda)
     self.mp1 = cudafy(nn.MaxPool2d(kernel_size=3, stride=2, padding=1),
                       self.use_cuda)
     self.res2a = cudafy(
         HALNetResBlockConv(stride=1,
                            filters1=64,
                            filters2=256,
                            padding_right1=1), self.use_cuda)
     self.res2b = cudafy(HALNetResBlockIDSkip(filters1=64, filters2=256),
                         self.use_cuda)
     self.res2c = cudafy(HALNetResBlockIDSkip(filters1=64, filters2=256),
                         self.use_cuda)
     self.res3a = cudafy(
         HALNetResBlockConv(stride=2,
                            filters1=128,
                            filters2=512,
                            padding_right3=1,
                            first_in_channels=256), self.use_cuda)
     self.interm_loss1 = cudafy(
         HALNetConvBlock(kernel_size=3,
                         stride=1,
                         filters=self.num_joints,
                         in_channels=512,
                         padding=1), self.use_cuda)
     self.interm_loss1_deconv = cudafy(
         nn.Upsample(scale_factor=4, mode='bilinear', align_corners=True),
         self.use_cuda)
     self.interm_loss1_softmax = cudafy(SoftmaxLogProbability2D(),
                                        self.use_cuda)
     self.res3b = cudafy(HALNetResBlockIDSkip(filters1=128, filters2=512),
                         self.use_cuda)
     self.res3c = cudafy(HALNetResBlockIDSkip(filters1=128, filters2=512),
                         self.use_cuda)
     self.res4a = cudafy(
         HALNetResBlockConv(stride=2,
                            filters1=256,
                            filters2=1024,
                            padding_right3=1,
                            first_in_channels=512), self.use_cuda)
     self.interm_loss2 = cudafy(
         HALNetConvBlock(kernel_size=3,
                         stride=1,
                         filters=self.num_joints,
                         in_channels=1024,
                         padding=1), self.use_cuda)
     self.interm_loss2_deconv = cudafy(
         nn.Upsample(scale_factor=8, mode='bilinear', align_corners=True),
         self.use_cuda)
     self.interm_loss2_softmax = cudafy(SoftmaxLogProbability2D(),
                                        self.use_cuda)
     self.res4b = cudafy(HALNetResBlockIDSkip(filters1=256, filters2=1024),
                         self.use_cuda)
     self.res4c = cudafy(HALNetResBlockIDSkip(filters1=256, filters2=1024),
                         self.use_cuda)
     self.res4d = cudafy(HALNetResBlockIDSkip(filters1=256, filters2=1024),
                         self.use_cuda)
     self.conv4e = cudafy(
         HALNetConvBlock(kernel_size=3,
                         stride=1,
                         filters=512,
                         in_channels=1024,
                         padding=1), self.use_cuda)
     self.interm_loss3 = cudafy(
         HALNetConvBlock(kernel_size=3,
                         stride=1,
                         filters=self.num_joints,
                         in_channels=512,
                         padding=1), self.use_cuda)
     self.interm_loss3_deconv = cudafy(
         nn.Upsample(scale_factor=8, mode='bilinear', align_corners=True),
         self.use_cuda)
     self.interm_loss3_softmax = cudafy(SoftmaxLogProbability2D(),
                                        self.use_cuda)
     self.conv4f = cudafy(
         HALNetConvBlock(kernel_size=3,
                         stride=1,
                         filters=256,
                         in_channels=512,
                         padding=1), self.use_cuda)
     self.main_loss_conv = cudafy(
         HALNetConvBlock(kernel_size=3,
                         stride=1,
                         filters=self.num_joints,
                         in_channels=256,
                         padding=1), self.use_cuda)
     self.main_loss_deconv = cudafy(
         nn.Upsample(scale_factor=8, mode='bilinear', align_corners=True),
         self.use_cuda)
     if self.cross_entropy:
         self.softmax_final = cudafy(SoftmaxLogProbability2D(),
                                     self.use_cuda)
コード例 #7
0
ファイル: JORNet.py プロジェクト: pauloabelha/handy
    def __init__(self, params_dict):
        super(JORNet, self).__init__(params_dict)

        self.num_joints = 20
        self.main_loss_conv = cudafy(HALNet.HALNetConvBlock(
                kernel_size=3, stride=1, filters=21, in_channels=256, padding=1),
            self.use_cuda)
        self.main_loss_deconv1 = cudafy(nn.Upsample(size=self.crop_res, mode='bilinear'), self.use_cuda)
        #self.main_loss_deconv2 = cudafy(nn.Upsample(scale_factor=1, mode='bilinear'),
        #                                self.use_cuda)
        if self.cross_entropy:
            self.softmax_final = cudafy(HALNet.
                                        SoftmaxLogProbability2D(), self.use_cuda)
        self.innerproduct1_joint1 = cudafy(
            nn.Linear(in_features=524288, out_features=200), self.use_cuda)
        self.innerproduct2_joint1 = cudafy(
            nn.Linear(in_features=200, out_features=self.num_joints * 3), self.use_cuda)

        self.innerproduct1_joint2 = cudafy(
            nn.Linear(in_features=262144, out_features=200), self.use_cuda)
        self.innerproduct2_joint2 = cudafy(
            nn.Linear(in_features=200, out_features=self.num_joints * 3), self.use_cuda)

        self.innerproduct1_joint3 = cudafy(
            nn.Linear(in_features=131072, out_features=200), self.use_cuda)
        self.innerproduct2_joint3 = cudafy(
            nn.Linear(in_features=200, out_features=self.num_joints * 3), self.use_cuda)

        self.innerproduct1_joint_main = cudafy(
            nn.Linear(in_features=65536, out_features=200), self.use_cuda)
        self.innerproduct2_join_main = cudafy(
            nn.Linear(in_features=200, out_features=self.num_joints * 3), self.use_cuda)