TFRecord Writer writing patches in unexpected ways

I have implemented this example notebook -a methodology to segment satellite imagery using Google Earth Engine (GEE) and Tensorflow- on my specific use case.

The final step in this pipeline is uploading inference imagery to GEE using TFRecord Writer and a mixer file from GEE.

However, when I view the inference imagery, there is a strange tiling issue that causes prediction images to be jumbled in an irregular grid.

Here is an image of the “ground truth”.

This image was exported to the Google Cloud bucket using ee.Image.Export in the form of a TF record

Here is an image of the model prediction.


Using the same mixer file generated by the ee.Image.Export method, I generated model predictions and uploaded them as an EE asset. I used the following code to write the tf_record to my cloud bucket:

BUCKET = 'your-gcloud-bucket'
out_image_base = 'Troubleshooting_TF_Writer'

out_image_file = 'gs://' + BUCKET + out_image_base + '.TFRecord'
writer =
    for predictionPatch in train_predictions:

        # Create an example.
        example = tf.train.Example(
              'ag_or_not': tf.train.Feature(
        # Write the example.

I would expect the uploaded image (#2) to be relatively consistent with the ground truth image, but instead, it appears to be split towards the middle, and the top half of the original image is placed on the bottom half.

A GEE link to visualize the issue can be found here.

Where in the Mixer file is the geographic spacing metadata found? What order does the tfrecord writer use to write prediction patches?