Created
August 24, 2021 14:19
-
-
Save dpoulopoulos/e9808d2b746188dc5109fbb38dfd8768 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for tfrec_num in range(num_tfrecods): | |
samples = annotations[(tfrec_num * num_samples) : ((tfrec_num + 1) * num_samples)] | |
with tf.io.TFRecordWriter( | |
tfrecords_dir + "/file_%.2i-%i.tfrec" % (tfrec_num, len(samples)) | |
) as writer: | |
for sample in samples: | |
image_path = f"{images_dir}/{sample['image_id']:012d}.jpg" | |
image = tf.io.decode_jpeg(tf.io.read_file(image_path)) | |
example = create_example(image, image_path, sample) | |
writer.write(example.SerializeToString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment