コード例 #1
0
def read_one_datum(fqueue, dim, key_num=36, hm_dim=64, nStack=4):
    reader = tf.TFRecordReader()
    key, value = reader.read(fqueue)
    basics = tf.parse_single_example(
        value,
        features={
            # 'key2d': tf.FixedLenFeature([key_num * 2], tf.float32),
            'key2d': tf.FixedLenFeature([key_num * 2], tf.float32),
            'image': tf.FixedLenFeature([], tf.string)
        })

    image = basics['image']
    image = tf.decode_raw(image, tf.uint8)
    image.set_shape([3 * dim * dim])
    image = tf.reshape(image, [dim, dim, 3])

    # appy resizing and hm generation
    # image = tf.image.resize_images(image, size=[256, 256]) # on need.... stick with 64 * 64... instead of 256 by 256, try...
    # print("img_shape sanity check",image)
    key = basics['key2d']

    key_resh = tf.reshape(key, shape=(key_num, 2))
    key_resh *= hm_dim  # to match hm_dimension

    key_hm = ut._tf_generate_hm(
        hm_dim, hm_dim, key_resh)  # tensor, (64, 64, 36), dtype=tf.float32
    temp = [key_hm for _ in range(nStack)]
    key_hm = tf.stack(temp, axis=0)
    # print("sanity check : key_hm", key_hm)
    # print("sanity check - image", image)
    return image, key_hm
コード例 #2
0
def read_one_datum(fqueue, dim, key_num=36, hm_dim=64, nStack=4):
    reader = tf.TFRecordReader()
    key, value = reader.read(fqueue)
    basics = tf.parse_single_example(value,
                                     features={
                                         'key2d':
                                         tf.FixedLenFeature([key_num * 2],
                                                            tf.float32),
                                         'key3d':
                                         tf.FixedLenFeature([key_num * 3],
                                                            tf.float32),
                                         'image':
                                         tf.FixedLenFeature([], tf.string)
                                     })

    image = basics['image']
    image = tf.decode_raw(image, tf.uint8)
    image.set_shape([3 * dim * dim])
    image = tf.reshape(image, [dim, dim, 3])

    k2d = basics['key2d']
    k3d = basics['key3d']

    # convert k2d to HMs(4stacks for sHG)
    key_resh = tf.reshape(k2d, shape=(key_num, 2))
    key_resh *= hm_dim  # to match hm_dimension

    key_hm = ut._tf_generate_hm(
        hm_dim, hm_dim, key_resh)  # tensor, (64, 64, 36), dtype=tf.float32
    temp = [key_hm for _ in range(nStack)]
    key_hm = tf.stack(temp, axis=0)

    return image, key_hm, k3d
コード例 #3
0
def read_one_datum(fqueue, dim, key_num=36, hm_dim=64, nStack=4):
  reader = tf.TFRecordReader()
  key, value = reader.read(fqueue)
  basics = tf.parse_single_example(value, features={
    # 'key2d': tf.FixedLenFeature([key_num * 2], tf.float32),
    'key2d': tf.FixedLenFeature([key_num * 2], tf.float32),

    'image': tf.FixedLenFeature([], tf.string)})

  image = basics['image']
  image = tf.decode_raw(image, tf.uint8)
  image.set_shape([3 * dim * dim])
  image = tf.reshape(image, [dim, dim, 3])


  # appy resizing and hm generation
  image = tf.image.resize_images(image, size=[256, 256])

  key = basics['key2d']

  key_resh = tf.reshape(key*hm_dim, shape=(key_num, 2))
  key_resh *= hm_dim
  key_hm = ut._tf_generate_hm(hm_dim, hm_dim, key_resh)
  temp = [key_hm for _ in range(nStack)]
  key_hm = tf.stack(temp, axis=0)
  # print(key_hm.get_shape().as_list())

  return image, key_hm