osc.data.tfrecords.serialize_image_and_mask

serialize_image_and_mask(image, mask)[source]

Serialize an image and a mask to be written to a TFRecord.

Parameters
  • image (Tensor) – uint8 tensor of shape [H W 3]

  • mask (Tensor) – bool tensor of shape [H W C], where C is the number of classes.

Example

When calling this function from a :mod:tf.data pipeline, wrap it in a :func:tf.py_function:

>>> tf.py_function(serialize_image_and_mask, (image, mask), tf.string)
Returns

A byte string.