Skip to content

TfRecordSSDReader

TfRecordSSDReader class

dlf.data_generators.tf_record_object_detection_reader.TfRecordSSDReader(
    labelmap,
    path=None,
    glob_pattern=None,
    image_key="image/encoded",
    bounding_box_key="image/object/bbox/",
    label_key="image/object/class/label",
    id_key="image/source_id",
    background_as_zero=True,
    shuffle=True,
    ignore=None,
    remap=None,
    preprocess_list=None,
    shuffle_buffer=2000,
)

A data generator which uses the TFRecord format for object detection tasks using SSD architectures

Arguments

  • path: str. Path to TFRecord file. Defaults to None.
  • glob_pattern: str. Glob pattern for multiple TFRecord files. This is the case if a record file was sharded over multiple files. Defaults to None.
  • labelmap: str. Path to labelmap related to TFRecord file
  • image_key: str. Key where the images are located in tf record example. Defaults to 'image/encoded'.
  • bounding_box_key: str. Key where the bounding boxes are located in tf record example Defaults to 'image/object/bbox/'.
  • label_key: str. Key where the labes are located. Defaults to 'image/object/class/label'.
  • id_key: str. Key where the images ids are lcoated. Defaults to 'image/source_id'.
  • background_as_zero: bool. If true, background with 0 zero will be added to label list. Defaults to True.
  • shuffle: bool. If true, dataset is shuffled. Defaults to True.
  • ignore: list of int. A list of integers where each number is ignored during validation e.g. label 255 in PascalVOC. Defaults to None.
  • remap: dict[int, int]. Dictionary where the key is the source category which is remaped to the value, target id. Defaults to None.
  • preprocess_list: dict. Dictionary where the value describes a preprocessing method and the values are the arguments. Defaults to None.
  • shuffle_buffer: int. Size of shuffle buffer. For details check: tf.data.Dataset. Defaults to 2000.

Raises

  • FileNotFoundError: If TFRecord file is not found
  • FileNotFoundError: If Labelmap file is not found

YAML Configuration

Sample configuration for a object detection reader that applies remapping and uses a list of pre-processing functions before passing the image to CNN.

input_reader:
    training_reader:
        name: tf_record_ssd_reader
        path: /mnt/data/datasets/wheeled_walker_100k_8fps_25switch/25k_sample_4_mask/training.tfrecord
        labelmap: &labelmap /mnt/data/datasets/wheeled_walker_100k_8fps_25switch/label_map.pbtxt
        ignore:
        remap:
            1:0
            2:0
            3:0
            5:1
            6:1
            7:1
        preprocess_list:
            h_flip:
            v_flip:
            resize:
                output_shape:
                    - 512
                    - 512
            saturation:
            brightness:
                max_delta: 0.6
            blur:
            noise:
                mean: 0
                std: 5