Image segmentation projects on Labelbox can now be exported as TFRecords for convenient and efficient usage by Tensorflow models.
See the end-to-end walkthrough using Tensorflow and Labelbox
After generating a TFRecord export from a project's export tab, a new task will appear under the "Tasks" button in the top navbar which upon completion will link to an
export.json file. This file contains a string-serialized JSON object with the following properties:
legend- An object mapping pixel values [1-255] within a segmentation map to the class label they represent. A pixel value of 0 is used to denote unlabeled pixels.
tfrecord_paths- An array of Google Cloud Storage URLs containing the exported TFRecords.
Each TFRecord contains a single
tf.train.Example with the following features:
tf.stringof the bytes of the encoded image. Can be decoded into a
tf.stringof the Google Cloud Storage URL of this image.
tf.stringof the ID of this image.
tf.stringof the format of this image.
tf.int64of the image's height.
image/width - Atf.int64` of the image's width.
tf.int64of the number of channels in this image.
tf.stringof the image's colorspace.
tf.stringof the bytes of the encoded segmentation map. Can be decoded into a
tf.stringrepresenting the image format of the encoded segmentation map.
A code example which uses Tensorflow's Datasets API to decode a Labelbox TFRecord export's
export.json into a directory of images and their segmentation maps is available here.
This code demonstrates how to use a TFRecords export from Labelbox in a Tensorflow image segmentation model.
By leveraging Tensorflow's Datasets API,
the end-to-end example is able to read its inputs directly from cloud storage.
This example was developed on Python 3.5.2.
TFRecord exports are hosted on Google Cloud Storage. To directly ingest them
from a Tensorflow Dataset Input Pipeline, Google Cloud SDK application default
credentials need to be configured.
gcloud auth application-default login
Install Python dependencies:
pip install -r requirements.txt
python example.py export.json
Monitor the model outputs at http://localhost:6006/
TODO: 3 layer CNN with FC layer replaced by another conv (FCN); no pooling => no upsampling