示例#1
0
    def model(self):
        outdims = self.__self_dict()
        fn = layers.l2_regularizer(1e-5)
        fn0 = tf.no_regularizer
        with slim.arg_scope([slim.conv2d, slim.fully_connected],
                            weights_regularizer=fn,
                            biases_regularizer=fn0,
                            normalizer_fn=slim.batch_norm):
            with slim.arg_scope([slim.batch_norm],
                                is_training=False,
                                updates_collections=None,
                                decay=0.9,
                                center=True,
                                scale=True,
                                epsilon=1e-5):
                pred_comb_ht, pred_comb_hand, pred_hand, pred_ht = basenet2(
                    self.inputs, kp=1, is_training=False, outdims=outdims)

        self.hand_tensor = pred_hand
import tensorflow.contrib.layers as layers

fn = layers.l2_regularizer(1e-5)
fn0 = tf.no_regularizer
with slim.arg_scope([slim.conv2d, slim.fully_connected],
                    weights_regularizer=fn,
                    biases_regularizer=fn0,
                    normalizer_fn=slim.batch_norm):
    with slim.arg_scope([slim.batch_norm],
                        is_training=is_train,
                        updates_collections=None,
                        decay=0.9,
                        center=True,
                        scale=True,
                        epsilon=1e-5):
        pred_comb_ht, pred_comb_hand, pred_hand, pred_ht = basenet2(
            inputs, kp=kp, is_training=is_train, outdims=outdims)

gt_palm_ht = tf.concat((gt_ht[:, :, :, 0:1], gt_ht[:, :, :, 1::4]), 3)
gt_fing_ht = tf.concat(
    (gt_ht[:, :, :, 2::4], gt_ht[:, :, :, 3::4], gt_ht[:, :, :, 4::4]), 3)

label1 = tf.reshape(label, (-1, 21, 3))
gt_fing = tf.reshape(
    tf.concat((label1[:, 2::4, :], label1[:, 3::4, :], label1[:, 4::4, :]), 1),
    (-1, 15 * 3))
gt_palm = tf.reshape(tf.concat((label1[:, 0:1, :], label1[:, 1::4, :]), 1),
                     (-1, 6 * 3))

loss_ht = tf.nn.l2_loss((pred_ht - gt_ht)) / batch_size
loss_hand = tf.nn.l2_loss((pred_hand - label)) / batch_size
fn = layers.l2_regularizer(1e-5)
fn0 = tf.no_regularizer

with slim.arg_scope([slim.conv2d, slim.fully_connected],
                    weights_regularizer=fn,
                    biases_regularizer=fn0,
                    normalizer_fn=slim.batch_norm):
    with slim.arg_scope([slim.batch_norm],
                        is_training=False,
                        updates_collections=None,
                        decay=0.9,
                        center=True,
                        scale=True,
                        epsilon=1e-5):
        pred_comb_ht, pred_comb_hand, pred_hand, pred_ht = basenet2(
            inputs, kp=1, is_training=False)

pred_out = pred_hand

import time

pred_norm = []
saver = tf.train.Saver(max_to_keep=5)
with tf.Session() as sess:
    init = tf.global_variables_initializer()
    sess.run(init)
    saver.restore(sess, '../../model/crossInfoNet_NYU.ckpt')
    loopv = test_num // batch_size
    other = test_data[loopv * batch_size:]
    a = time.time()
    for i in xrange(loopv + 1):