in 1_prepare_data/docker/code/utils/tf_record_util.py [0:0]
def generate_tf_records(self):
with jsonlines.open(self.manifest, 'r') as reader:
ground_truth_annotations = list(reader)
dataset = split_dataset(ground_truth_annotations)
for subset in dataset:
logging.info(f'GENERATING TF RECORD FOR {subset}')
writer = tf.io.TFRecordWriter(os.path.join(self.output_dir, f'{subset}.records'))
for image_annotations in dataset[subset]:
annotation_dict = json.loads(json.dumps(image_annotations))
tf_example = self._create_tf_example(annotation_dict['source-ref'],
annotation_dict['bees-500']['annotations'])
writer.write(tf_example.SerializeToString())
writer.close()