A Decoder class to decode examples

tefla.dataset.decoder.Decoder (feature_keys)

Args

  • feature_keys: a dict, with features name and data types
  • e.g.: features_keys = {'image/encoded/image': tf.FixedLenFeature((), tf.string, default_value=''),'image/format': tf.FixedLenFeature((), tf.string, default_value='jpg'),'image/class/label': tf.FixedLenFeature([], tf.int64, - default_value=tf.zeros([], dtype=tf.int64)), }

Methods

decode (example_serialized, image_size, resize_size=None)

Args

  • example_serialized: scalar Tensor tf.string containing a serialized Example protocol buffer.
  • Returns: image_buffer: Tensor tf.string containing the contents of a JPEG file. label: Tensor tf.int32 containing the label. text: Tensor tf.string containing the human-readable label.
Returns

image_buffer: Tensor tf.string containing the contents of a JPEG file. label: Tensor tf.int32 containing the label. text: Tensor tf.string containing the human-readable label.

distort_image (image, distort_op, height, width, thread_id=0, scope=None)

Args

  • image: 3-D float Tensor of image
  • height: integer
  • width: integer
  • thread_id: integer indicating the preprocessing thread.
  • scope: Optional scope for name_scope.

    Returns

  • 3-D float Tensor of distorted image used for training.

Returns

3-D float Tensor of distorted image used for training.

eval_image (image, height, width, scope=None)

Args

  • image: 3-D float Tensor
  • height: integer
  • width: integer
  • scope: Optional scope for name_scope.

    Returns

  • 3-D float Tensor of prepared image.

Returns

3-D float Tensor of prepared image.

parse_example_proto (example_serialized, is_bbox=False) The output of the build_image_data.py image preprocessing script is a dataset containing serialized Example protocol buffers. Each Example proto contains the following fields: image/height: 462 image/width: 581 image/colorspace: 'RGB' image/channels: 3 image/class/label: 615 image/class/synset: 'n03623198' image/class/text: 'knee pad' image/object/bbox/xmin: 0.1 image/object/bbox/xma

x

0.9 image/object/bbox/ymin: 0.2 image/object/bbox/yma

x

0.6 image/object/bbox/label: 615 image/format: 'JPEG' image/filename: 'ILSVRC2012_val_00041207.JPEG' image/encoded:

Args
  • example_serialized: scalar Tensor tf.string containing a serialized
  • Example protocol buffer.
Returns

image_buffer: Tensor tf.string containing the contents of a JPEG file. label: Tensor tf.int32 containing the label. bbo

x

3-D float Tensor of bounding boxes arranged [1, num_boxes, coords] where each coordinate is [0, 1) and the coordinates are arranged as [ymin, xmin, ymax, xmax]. text: Tensor tf.string containing the human-readable label.