in machine_learning/ml_infrastructure/inference-server-performance/server/scripts/tensorrt-optimization.py [0:0]
def deserialize_image_record(record):
keys_to_features = {
'image/encoded': tf.FixedLenFeature((), tf.string, ''),
'image/class/label': tf.FixedLenFeature([], tf.int64, -1),
}
with tf.name_scope('deserialize_image_record'):
parsed = tf.parse_single_example(record, keys_to_features)
image_bytes = tf.reshape(parsed['image/encoded'], shape=[])
label = tf.cast(tf.reshape(parsed['image/class/label'], shape=[]),
dtype=tf.int32)
# 'image/class/label' is encoded as an integer from 1 to
# num_label_classes in order to generate the correct one-hot label
# vector from this number, we subtract the number by 1 to make it
# in [0, num_label_classes).
label -= 1
return image_bytes, label