Exemple #1
0
def keynn_64(image, pose_dim, reuse_flag, tp):

    prefix = 'conv'
    with tf.variable_scope('Base_CNN', reuse=reuse_flag):
        inet = net2d.stack_modern_conv(prefix,
                                       1,
                                       5,
                                       image,
                                       3,
                                       64,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)
        inet = net2d.stack_modern_conv(prefix,
                                       5,
                                       10,
                                       inet,
                                       3,
                                       128,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)
        inet = net2d.stack_modern_conv(prefix,
                                       10,
                                       15,
                                       inet,
                                       3,
                                       256,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)
        inet = net2d.stack_modern_conv(prefix,
                                       15,
                                       20,
                                       inet,
                                       3,
                                       512,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)
        inet = net2d.stack_modern_conv(prefix,
                                       20,
                                       25,
                                       inet,
                                       3,
                                       512,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)

        vout = net2d.GAP('vGAP', inet)
        pred_pose = net2d.FC('pose', vout, pose_dim)

        return pred_pose
Exemple #2
0
def prep_sHG_3d_encode_info_v2(image, k3d_dim, reuse_flag, tp):
    prefix = 'conv'
    with tf.variable_scope('Base_CNN', reuse=reuse_flag):
        inet = net2d.stack_modern_conv(
            prefix,
            1,
            5,
            image,
            3,
            64,
            # int image: shape=(100, 64, 64, 3), out shape=(100, 64, 64, 64)
            is_training=tp,
            dropout=0.7,
            down_first=False)
        inet = net2d.stack_modern_conv(
            prefix,
            5,
            10,
            inet,
            3,
            128,  # out shape=(100, 32, 32, 128)
            is_training=tp,
            dropout=0.7,
            down_first=True)

        inet = net2d.stack_modern_conv(
            prefix,
            10,
            15,
            inet,
            3,
            256,  # out shape=(100, 16, 16, 256) # good enough for hourglass input.. i guess
            is_training=tp,
            dropout=0.7,
            down_first=True)

        hg_input = inet
        inet2 = net2d.stack_modern_conv(
            prefix,
            15,
            20,
            inet,
            3,
            512,  # out shape=(100, 8, 8, 512)
            is_training=tp,
            dropout=0.7,
            down_first=True)

        # check

        out_3d = net2d.GAP('vGAP', inet2)
        pred3d = net2d.FC('3d', out_3d, k3d_dim)
        return hg_input, pred3d
Exemple #3
0
def prep_sHG_3d_encode_info(image, k2d_dim, k3d_dim, reuse_flag, tp):
    prefix = 'conv'
    with tf.variable_scope('Base_CNN', reuse=reuse_flag):
        inet = net2d.stack_modern_conv(
            prefix,
            1,
            5,
            image,
            3,
            64,
            # int image: shape=(100, 64, 64, 3), out shape=(100, 64, 64, 64)
            is_training=tp,
            dropout=0.7,
            down_first=False)
        inet = net2d.stack_modern_conv(
            prefix,
            5,
            10,
            inet,
            3,
            128,  # out shape=(100, 32, 32, 128)
            is_training=tp,
            dropout=0.7,
            down_first=True)

        inet = net2d.stack_modern_conv(
            prefix,
            10,
            15,
            inet,
            3,
            256,  # out shape=(100, 16, 16, 256)
            is_training=tp,
            dropout=0.7,
            down_first=True)
        # inet = net2d.stack_modern_conv(prefix, 15, 20, inet, 3, 512,  # out shape=(100, 8, 8, 512)
        #                                is_training=tp, dropout=0.7, down_first=True)

        # check

        return inet
Exemple #4
0
def base_64_ds_key_vnn(image, depth, pose_dim, mask_dim, key_dim, reuse_flag,
                       tp):
    n = image.get_shape().as_list()[0]
    prefix = 'conv'
    with tf.variable_scope('Base_CNN', reuse=reuse_flag):
        inet = net2d.stack_modern_conv(prefix,
                                       1,
                                       5,
                                       image,
                                       3,
                                       64,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)
        inet = net2d.stack_modern_conv(prefix,
                                       5,
                                       10,
                                       inet,
                                       3,
                                       128,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)
        inet = net2d.stack_modern_conv(prefix,
                                       10,
                                       15,
                                       inet,
                                       3,
                                       256,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)

        dnet = net2d.stack_modern_conv(prefix + '_depth',
                                       1,
                                       5,
                                       depth,
                                       3,
                                       64,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)
        dnet = net2d.stack_modern_conv(prefix + '_depth',
                                       5,
                                       10,
                                       dnet,
                                       3,
                                       128,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)
        dnet = net2d.stack_modern_conv(prefix + '_depth',
                                       10,
                                       15,
                                       dnet,
                                       3,
                                       128,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)

        idnet = tf.concat([inet, dnet], axis=3)

        mask_out = tf.reshape(idnet, [n, -1])
        pred_mask = net2d.FC('mout', mask_out, mask_dim * 2)

        idnet = net2d.stack_modern_conv(prefix,
                                        15,
                                        18,
                                        idnet,
                                        3,
                                        512,
                                        is_training=tp,
                                        dropout=0.7,
                                        down_first=True)

        vout = net2d.GAP('vGAP', idnet)
        pred_bin = net2d.FC('bin', vout, pose_dim)

        idnet = net2d.stack_modern_conv(prefix,
                                        18,
                                        22,
                                        idnet,
                                        3,
                                        512,
                                        is_training=tp,
                                        dropout=0.7,
                                        down_first=False)

        key_out = net2d.GAP('kGAP', idnet)
        pred_key = net2d.FC('kout', key_out, key_dim)

        return pred_bin, pred_mask, pred_key
Exemple #5
0
def base_64_key_vnn(image, depth, key_dim, reuse_flag, tp):
    prefix = 'conv'
    with tf.variable_scope('Base_CNN', reuse=reuse_flag):
        inet = net2d.stack_modern_conv(prefix,
                                       1,
                                       5,
                                       image,
                                       3,
                                       64,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)
        inet = net2d.stack_modern_conv(prefix,
                                       5,
                                       10,
                                       inet,
                                       3,
                                       128,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)
        inet = net2d.stack_modern_conv(prefix,
                                       10,
                                       15,
                                       inet,
                                       3,
                                       256,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)

        dnet = net2d.stack_modern_conv(prefix + '_depth',
                                       1,
                                       5,
                                       depth,
                                       3,
                                       64,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)
        dnet = net2d.stack_modern_conv(prefix + '_depth',
                                       5,
                                       10,
                                       dnet,
                                       3,
                                       128,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)
        dnet = net2d.stack_modern_conv(prefix + '_depth',
                                       10,
                                       15,
                                       dnet,
                                       3,
                                       128,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)

        idnet = tf.concat([inet, dnet], axis=3)

        idnet = net2d.stack_modern_conv(prefix,
                                        15,
                                        22,
                                        idnet,
                                        3,
                                        512,
                                        is_training=tp,
                                        dropout=0.7,
                                        down_first=True)

        key_out = net2d.GAP('kGAP', idnet)
        pred_key = net2d.FC('kout', key_out, key_dim)

        return pred_key
Exemple #6
0
def keyos_64_for_hg(image, key_dim, reuse_flag, tp):
    prefix = 'conv'
    with tf.variable_scope('Base_CNN', reuse=reuse_flag):
        inet = net2d.stack_modern_conv(prefix,
                                       1,
                                       5,
                                       image,
                                       3,
                                       64,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)
        inet = net2d.stack_modern_conv(
            prefix,
            5,
            10,
            inet,
            3,
            128,
            is_training=tp,
            dropout=0.7,
            down_first=True)  # [h, w, c] = [64, 64, 64]
        inet = net2d.stack_modern_conv(prefix,
                                       10,
                                       15,
                                       inet,
                                       3,
                                       256,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)  # [16, 16, 256]

        inet = net2d.stack_modern_conv(prefix,
                                       15,
                                       18,
                                       inet,
                                       3,
                                       512,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)  # [8, 8, 512]
        inet1 = tf.image.resize_nearest_neighbor(inet,
                                                 size=[64, 64])  # 64, 64, 512
        out_os = net2d.GAP('osGAP', inet)
        pred_os = net2d.FC('os', out_os, key_dim)

        inet = net2d.stack_modern_conv(prefix,
                                       18,
                                       21,
                                       inet,
                                       3,
                                       512,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)  # [4, 4, 512]
        inet2 = tf.image.resize_nearest_neighbor(inet, size=[64, 64])

        out_3d = net2d.GAP('3dGAP', inet)
        pred3d = net2d.FC('3d', out_3d, key_dim * 3)

        inet = net2d.stack_modern_conv(prefix,
                                       21,
                                       25,
                                       inet,
                                       3,
                                       512,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)  # [4, 4, 512]
        inet3 = tf.image.resize_nearest_neighbor(inet, size=[64, 64])

        out_2d = net2d.GAP('2dGAP', inet)
        pred2d = net2d.FC('2d', out_2d, key_dim * 2)
        return pred2d, pred3d, pred_os, tf.add_n([inet1, inet2, inet3])
Exemple #7
0
def keyos_64(image, key_dim, reuse_flag, tp):

    prefix = 'conv'
    with tf.variable_scope('Base_CNN', reuse=reuse_flag):
        inet = net2d.stack_modern_conv(prefix,
                                       1,
                                       5,
                                       image,
                                       3,
                                       64,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)
        inet = net2d.stack_modern_conv(prefix,
                                       5,
                                       10,
                                       inet,
                                       3,
                                       128,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)
        inet = net2d.stack_modern_conv(prefix,
                                       10,
                                       15,
                                       inet,
                                       3,
                                       256,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)
        inet = net2d.stack_modern_conv(prefix,
                                       15,
                                       18,
                                       inet,
                                       3,
                                       512,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)

        out_os = net2d.GAP('osGAP', inet)
        pred_os = net2d.FC('os', out_os, key_dim)

        inet = net2d.stack_modern_conv(prefix,
                                       18,
                                       21,
                                       inet,
                                       3,
                                       512,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=True)

        out_3d = net2d.GAP('3dGAP', inet)
        pred3d = net2d.FC('3d', out_3d, key_dim * 3)

        inet = net2d.stack_modern_conv(prefix,
                                       21,
                                       25,
                                       inet,
                                       3,
                                       512,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)

        out_2d = net2d.GAP('2dGAP', inet)
        pred2d = net2d.FC('2d', out_2d, key_dim * 2)

        return pred2d, pred3d, pred_os
Exemple #8
0
def key23d_64(image, k2d_dim, k3d_dim, reuse_flag, tp):

    prefix = 'conv'
    with tf.variable_scope('Base_CNN', reuse=reuse_flag):
        inet = net2d.stack_modern_conv(
            prefix,
            1,
            5,
            image,
            3,
            64,  # int image: shape=(100, 64, 64, 3), out shape=(100, 64, 64, 64)
            is_training=tp,
            dropout=0.7,
            down_first=False)
        inet = net2d.stack_modern_conv(
            prefix,
            5,
            10,
            inet,
            3,
            128,  # out shape=(100, 32, 32, 128)
            is_training=tp,
            dropout=0.7,
            down_first=True)

        inet = net2d.stack_modern_conv(
            prefix,
            10,
            15,
            inet,
            3,
            256,  # out shape=(100, 16, 16, 256)
            is_training=tp,
            dropout=0.7,
            down_first=True)
        inet = net2d.stack_modern_conv(
            prefix,
            15,
            20,
            inet,
            3,
            512,  # out shape=(100, 8, 8, 512)
            is_training=tp,
            dropout=0.7,
            down_first=True)

        # check
        out_3d = net2d.GAP('vGAP', inet)
        pred3d = net2d.FC('3d', out_3d, k3d_dim)

        inet = net2d.stack_modern_conv(prefix,
                                       20,
                                       25,
                                       inet,
                                       3,
                                       512,
                                       is_training=tp,
                                       dropout=0.7,
                                       down_first=False)

        out_2d = net2d.GAP('vGAP', inet)
        pred2d = net2d.FC('2d', out_2d, k2d_dim)

        return pred2d, pred3d