(argv)
| 72 | |
| 73 | |
| 74 | def main(argv): |
| 75 | if len(argv) > 1: |
| 76 | raise app.UsageError("Too many command-line arguments.") |
| 77 | |
| 78 | tf.logging.set_verbosity(tf.logging.INFO) |
| 79 | tf.io.gfile.makedirs(FLAGS.output_dir) |
| 80 | |
| 81 | pattern = "%s/%s-*" % (FLAGS.sqa_path, FLAGS.split) |
| 82 | questions = load_synthetic_questions(pattern) |
| 83 | |
| 84 | # Convert to ImageMetadata. |
| 85 | images = [] |
| 86 | for image_id, data in questions.items(): |
| 87 | metadata = image_utils.ImageMetadata( |
| 88 | image_id=image_id, |
| 89 | question_ids=data["question_ids"], |
| 90 | questions=data["questions"], |
| 91 | answers=data["answers"], |
| 92 | captions=data["captions"], |
| 93 | objects="%s/%s_features.hdf5" % (FLAGS.coco_path, FLAGS.split)) |
| 94 | images.append(metadata) |
| 95 | |
| 96 | # Dump to sharded TFRecords. |
| 97 | io_utils.convert_to_tfrecords( |
| 98 | dataset=images, |
| 99 | num_shards=FLAGS.num_shards, |
| 100 | basename=os.path.join(FLAGS.output_dir, FLAGS.split), |
| 101 | example_fn=io_utils.vqa_example) |
| 102 | |
| 103 | |
| 104 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected
searching dependent graphs…