Friday, September 20, 2019

Creating and consuming tensorflow record files

TFRecord files can be confusing. They are the preferred data containers for training tensorflow models when using the object detection api (github).

It took me a while to converge on code I like for generating TFRecord files (including hard negative examples, with no bounding boxes), and for consuming TFRecord files to display their contents. The latter is especially important, as when you roll your own augmentation pipeline it is really helpful to look at the data that your are using to train your network, just to be sure everything looks reasonable.

I've encapsulated my experience with this in a github repo, tfrecord-view, which has a script for encoding data into a TFRecord file (given images and VOC-Pascal encoded xml annotation files), and a script for consuming a TFRecord file:

https://github.com/EricThomson/tfrecord-view

It includes data and annotation files so you can test it out easily.