E621 TFRecords to train classifiers and other stuff with my codebases.
TFRecord serialization/deserialization code:
NUM_CLASSES = 8783
Function to convert value to bytes_list
def _bytes_feature(value):
if isinstance(value, type(tf.constant(0))):
value = value.numpy()
elif isinstance(value, str):
value = value.encode()
return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))