def testInt64Parser(self):
    int_val = [1, 2, 3]
    features = {'ints': self._Int64Feature(int_val)}
    example = tf.train.Example(features=tf.train.Features(feature=features))

    parser = tf_example_parser.Int64Parser('ints')
    result = parser.parse(example)
    self.assertIsNotNone(result)
    np_testing.assert_almost_equal(result, int_val)

    parser = tf_example_parser.Int64Parser('another_ints')
    result = parser.parse(example)
    self.assertIsNone(result)
Exemple #2
0
 def __init__(self):
     self.items_to_handlers = {
         fields.DetectionResultFields.key:
         StringParser(fields.TfExampleFields.source_id),
         # Object detections.
         fields.DetectionResultFields.detection_boxes:
         (tf_example_parser.BoundingBoxParser(
             fields.TfExampleFields.detection_bbox_xmin,
             fields.TfExampleFields.detection_bbox_ymin,
             fields.TfExampleFields.detection_bbox_xmax,
             fields.TfExampleFields.detection_bbox_ymax)),
         fields.DetectionResultFields.detection_classes:
         (tf_example_parser.Int64Parser(
             fields.TfExampleFields.detection_class_label)),
         fields.DetectionResultFields.detection_scores:
         (tf_example_parser.FloatParser(
             fields.TfExampleFields.detection_score)),
     }
     self.optional_items_to_handlers = {}