class_docstr: Writes object detection dataset into tfrecords.
  
  Reads dataset from a subclass of ObjectDetectionReader and saves it using
  the default format for tfrecords.
class_docstr_tok: ["Writes","object","detection","dataset","into","tfrecords",".","Reads","dataset","from","a","subclass","of","ObjectDetectionReader","and","saves","it","using","the","default","format","for","tfrecords","."]
docstr: Creates tf.train.SequenceExample object from records.
          
docstr_tok: ["Creates","tf.train.SequenceExample","object","from","records","."]
code: def _record_to_tf(self, record):
      """Creates tf.train.SequenceExample object from records."""
      try:
          self._validate_record(record)
      except InvalidRecord as e:
          # Pop image before displaying record.
          record.pop("image_raw")
          tf.logging.warning(
              "Invalid record: {} - {}".format(e, record)
          )
          return
  
      sequence_vals = {
          "label": [],
          "xmin": [],
          "ymin": [],
          "xmax": [],
          "ymax": [],
      }
  
      for b in record["gt_boxes"]:
          sequence_vals["label"].append(to_int64(b["label"]))
          sequence_vals["xmin"].append(to_int64(b["xmin"]))
          sequence_vals["ymin"].append(to_int64(b["ymin"]))
          sequence_vals["xmax"].append(to_int64(b["xmax"]))
          sequence_vals["ymax"].append(to_int64(b["ymax"]))
  
      object_feature_lists = {
          "label": tf.train.FeatureList(feature=sequence_vals["label"]),
          "xmin": tf.train.FeatureList(feature=sequence_vals["xmin"]),
          "ymin": tf.train.FeatureList(feature=sequence_vals["ymin"]),
          "xmax": tf.train.FeatureList(feature=sequence_vals["xmax"]),
          "ymax": tf.train.FeatureList(feature=sequence_vals["ymax"]),
      }
  
      object_features = tf.train.FeatureLists(
          feature_list=object_feature_lists
      )
  
      feature = {
          "width": to_int64(record["width"]),
          "height": to_int64(record["height"]),
          "depth": to_int64(record["depth"]),
          "filename": to_string(record["filename"]),
          "image_raw": to_bytes(record["image_raw"]),
      }
  
      # Now build an `Example` protobuf object and save with the writer.
      context = tf.train.Features(feature=feature)
      example = tf.train.SequenceExample(
          feature_lists=object_features, context=context
      )
  
      return example
  
file_path: luminoth/luminoth/tools/dataset/writers/object_detection_writer.py
imports: import click
  import json
  import os
  import tensorflow
  from .base_writer import BaseWriter
  from luminoth.tools.dataset.readers import ObjectDetectionReader
  from luminoth.utils.dataset import to_int64, to_string, to_bytes
label_desc: Use image node_id 4 for calling the ObjectDetectionWriter obj's underlying member method code with example usage: obj._record_to_tf(record) and returns: example