Python object_detection.protos.box_coder_pb2.BoxCoder() Examples

The following are 30 code examples of object_detection.protos.box_coder_pb2.BoxCoder(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module object_detection.protos.box_coder_pb2 , or try the search function .
Example #1
Source File: box_coder_builder_test.py    From Gun-Detector with Apache License 2.0 6 votes vote down vote up
def test_build_keypoint_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      keypoint_box_coder {
        num_keypoints: 6
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object, keypoint_box_coder.KeypointBoxCoder)
    self.assertEqual(box_coder_object._num_keypoints, 6)
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #2
Source File: box_coder_builder_test.py    From Traffic-Rule-Violation-Detection-System with MIT License 6 votes vote down vote up
def test_build_keypoint_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      keypoint_box_coder {
        num_keypoints: 6
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object, keypoint_box_coder.KeypointBoxCoder)
    self.assertEqual(box_coder_object._num_keypoints, 6)
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #3
Source File: box_coder_builder_test.py    From ros_people_object_detection_tensorflow with Apache License 2.0 6 votes vote down vote up
def test_build_keypoint_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      keypoint_box_coder {
        num_keypoints: 6
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object, keypoint_box_coder.KeypointBoxCoder)
    self.assertEqual(box_coder_object._num_keypoints, 6)
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #4
Source File: box_coder_builder_test.py    From vehicle_counting_tensorflow with MIT License 6 votes vote down vote up
def test_build_keypoint_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      keypoint_box_coder {
        num_keypoints: 6
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object, keypoint_box_coder.KeypointBoxCoder)
    self.assertEqual(box_coder_object._num_keypoints, 6)
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #5
Source File: box_coder_builder_test.py    From yolo_v2 with Apache License 2.0 6 votes vote down vote up
def test_build_keypoint_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      keypoint_box_coder {
        num_keypoints: 6
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object, keypoint_box_coder.KeypointBoxCoder)
    self.assertEqual(box_coder_object._num_keypoints, 6)
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #6
Source File: box_coder_builder_test.py    From Person-Detection-and-Tracking with MIT License 6 votes vote down vote up
def test_build_keypoint_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      keypoint_box_coder {
        num_keypoints: 6
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object, keypoint_box_coder.KeypointBoxCoder)
    self.assertEqual(box_coder_object._num_keypoints, 6)
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #7
Source File: box_coder_builder_test.py    From Traffic-Rule-Violation-Detection-System with MIT License 5 votes vote down vote up
def test_build_faster_rcnn_box_coder_with_defaults(self):
    box_coder_text_proto = """
      faster_rcnn_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object,
                          faster_rcnn_box_coder.FasterRcnnBoxCoder)
    self.assertEqual(box_coder_object._scale_factors, [10.0, 10.0, 5.0, 5.0]) 
Example #8
Source File: box_coder_builder_test.py    From Gun-Detector with Apache License 2.0 5 votes vote down vote up
def test_build_faster_rcnn_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      faster_rcnn_box_coder {
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object,
                          faster_rcnn_box_coder.FasterRcnnBoxCoder)
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #9
Source File: box_coder_builder_test.py    From Gun-Detector with Apache License 2.0 5 votes vote down vote up
def test_build_keypoint_box_coder_with_defaults(self):
    box_coder_text_proto = """
      keypoint_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object, keypoint_box_coder.KeypointBoxCoder)
    self.assertEqual(box_coder_object._scale_factors, [10.0, 10.0, 5.0, 5.0]) 
Example #10
Source File: box_coder_builder_test.py    From Gun-Detector with Apache License 2.0 5 votes vote down vote up
def test_build_faster_rcnn_box_coder_with_defaults(self):
    box_coder_text_proto = """
      faster_rcnn_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object,
                          faster_rcnn_box_coder.FasterRcnnBoxCoder)
    self.assertEqual(box_coder_object._scale_factors, [10.0, 10.0, 5.0, 5.0]) 
Example #11
Source File: box_coder_builder_test.py    From tensorflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_build_square_box_coder_with_defaults(self):
    box_coder_text_proto = """
      square_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(
        isinstance(box_coder_object, square_box_coder.SquareBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [10.0, 10.0, 5.0]) 
Example #12
Source File: box_coder_builder_test.py    From tensorflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_build_mean_stddev_box_coder(self):
    box_coder_text_proto = """
      mean_stddev_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(
        isinstance(box_coder_object,
                   mean_stddev_box_coder.MeanStddevBoxCoder)) 
Example #13
Source File: box_coder_builder_test.py    From tensorflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_build_faster_rcnn_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      faster_rcnn_box_coder {
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(isinstance(box_coder_object,
                               faster_rcnn_box_coder.FasterRcnnBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #14
Source File: box_coder_builder_test.py    From tensorflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_build_faster_rcnn_box_coder_with_defaults(self):
    box_coder_text_proto = """
      faster_rcnn_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(isinstance(box_coder_object,
                               faster_rcnn_box_coder.FasterRcnnBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [10.0, 10.0, 5.0, 5.0]) 
Example #15
Source File: box_coder_builder_test.py    From tensorflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_build_square_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      square_box_coder {
        y_scale: 6.0
        x_scale: 3.0
        length_scale: 7.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(
        isinstance(box_coder_object, square_box_coder.SquareBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0]) 
Example #16
Source File: box_coder_builder.py    From garbage-object-detection-tensorflow with MIT License 5 votes vote down vote up
def build(box_coder_config):
  """Builds a box coder object based on the box coder config.

  Args:
    box_coder_config: A box_coder.proto object containing the config for the
      desired box coder.

  Returns:
    BoxCoder based on the config.

  Raises:
    ValueError: On empty box coder proto.
  """
  if not isinstance(box_coder_config, box_coder_pb2.BoxCoder):
    raise ValueError('box_coder_config not of type box_coder_pb2.BoxCoder.')

  if box_coder_config.WhichOneof('box_coder_oneof') == 'faster_rcnn_box_coder':
    return faster_rcnn_box_coder.FasterRcnnBoxCoder(scale_factors=[
        box_coder_config.faster_rcnn_box_coder.y_scale,
        box_coder_config.faster_rcnn_box_coder.x_scale,
        box_coder_config.faster_rcnn_box_coder.height_scale,
        box_coder_config.faster_rcnn_box_coder.width_scale
    ])
  if (box_coder_config.WhichOneof('box_coder_oneof') ==
      'mean_stddev_box_coder'):
    return mean_stddev_box_coder.MeanStddevBoxCoder()
  if box_coder_config.WhichOneof('box_coder_oneof') == 'square_box_coder':
    return square_box_coder.SquareBoxCoder(scale_factors=[
        box_coder_config.square_box_coder.y_scale,
        box_coder_config.square_box_coder.x_scale,
        box_coder_config.square_box_coder.length_scale
    ])
  raise ValueError('Empty box coder.') 
Example #17
Source File: box_coder_builder_test.py    From garbage-object-detection-tensorflow with MIT License 5 votes vote down vote up
def test_build_square_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      square_box_coder {
        y_scale: 6.0
        x_scale: 3.0
        length_scale: 7.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(
        isinstance(box_coder_object, square_box_coder.SquareBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0]) 
Example #18
Source File: box_coder_builder_test.py    From Traffic-Rule-Violation-Detection-System with MIT License 5 votes vote down vote up
def test_build_faster_rcnn_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      faster_rcnn_box_coder {
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object,
                          faster_rcnn_box_coder.FasterRcnnBoxCoder)
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #19
Source File: box_coder_builder_test.py    From HereIsWally with MIT License 5 votes vote down vote up
def test_build_square_box_coder_with_defaults(self):
    box_coder_text_proto = """
      square_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(
        isinstance(box_coder_object, square_box_coder.SquareBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [10.0, 10.0, 5.0]) 
Example #20
Source File: box_coder_builder_test.py    From yolo_v2 with Apache License 2.0 5 votes vote down vote up
def test_raise_error_on_empty_box_coder(self):
    box_coder_text_proto = """
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    with self.assertRaises(ValueError):
      box_coder_builder.build(box_coder_proto) 
Example #21
Source File: box_coder_builder_test.py    From yolo_v2 with Apache License 2.0 5 votes vote down vote up
def test_build_square_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      square_box_coder {
        y_scale: 6.0
        x_scale: 3.0
        length_scale: 7.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(
        isinstance(box_coder_object, square_box_coder.SquareBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0]) 
Example #22
Source File: box_coder_builder_test.py    From HereIsWally with MIT License 5 votes vote down vote up
def test_build_faster_rcnn_box_coder_with_defaults(self):
    box_coder_text_proto = """
      faster_rcnn_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(isinstance(box_coder_object,
                               faster_rcnn_box_coder.FasterRcnnBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [10.0, 10.0, 5.0, 5.0]) 
Example #23
Source File: box_coder_builder_test.py    From yolo_v2 with Apache License 2.0 5 votes vote down vote up
def test_build_mean_stddev_box_coder(self):
    box_coder_text_proto = """
      mean_stddev_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(
        isinstance(box_coder_object,
                   mean_stddev_box_coder.MeanStddevBoxCoder)) 
Example #24
Source File: box_coder_builder_test.py    From HereIsWally with MIT License 5 votes vote down vote up
def test_build_faster_rcnn_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      faster_rcnn_box_coder {
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(isinstance(box_coder_object,
                               faster_rcnn_box_coder.FasterRcnnBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #25
Source File: box_coder_builder_test.py    From yolo_v2 with Apache License 2.0 5 votes vote down vote up
def test_build_keypoint_box_coder_with_defaults(self):
    box_coder_text_proto = """
      keypoint_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object, keypoint_box_coder.KeypointBoxCoder)
    self.assertEqual(box_coder_object._scale_factors, [10.0, 10.0, 5.0, 5.0]) 
Example #26
Source File: box_coder_builder_test.py    From HereIsWally with MIT License 5 votes vote down vote up
def test_build_mean_stddev_box_coder(self):
    box_coder_text_proto = """
      mean_stddev_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(
        isinstance(box_coder_object,
                   mean_stddev_box_coder.MeanStddevBoxCoder)) 
Example #27
Source File: box_coder_builder_test.py    From yolo_v2 with Apache License 2.0 5 votes vote down vote up
def test_build_faster_rcnn_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      faster_rcnn_box_coder {
        y_scale: 6.0
        x_scale: 3.0
        height_scale: 7.0
        width_scale: 8.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object,
                          faster_rcnn_box_coder.FasterRcnnBoxCoder)
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0, 8.0]) 
Example #28
Source File: box_coder_builder_test.py    From yolo_v2 with Apache License 2.0 5 votes vote down vote up
def test_build_faster_rcnn_box_coder_with_defaults(self):
    box_coder_text_proto = """
      faster_rcnn_box_coder {
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertIsInstance(box_coder_object,
                          faster_rcnn_box_coder.FasterRcnnBoxCoder)
    self.assertEqual(box_coder_object._scale_factors, [10.0, 10.0, 5.0, 5.0]) 
Example #29
Source File: box_coder_builder.py    From HereIsWally with MIT License 5 votes vote down vote up
def build(box_coder_config):
  """Builds a box coder object based on the box coder config.

  Args:
    box_coder_config: A box_coder.proto object containing the config for the
      desired box coder.

  Returns:
    BoxCoder based on the config.

  Raises:
    ValueError: On empty box coder proto.
  """
  if not isinstance(box_coder_config, box_coder_pb2.BoxCoder):
    raise ValueError('box_coder_config not of type box_coder_pb2.BoxCoder.')

  if box_coder_config.WhichOneof('box_coder_oneof') == 'faster_rcnn_box_coder':
    return faster_rcnn_box_coder.FasterRcnnBoxCoder(scale_factors=[
        box_coder_config.faster_rcnn_box_coder.y_scale,
        box_coder_config.faster_rcnn_box_coder.x_scale,
        box_coder_config.faster_rcnn_box_coder.height_scale,
        box_coder_config.faster_rcnn_box_coder.width_scale
    ])
  if (box_coder_config.WhichOneof('box_coder_oneof') ==
      'mean_stddev_box_coder'):
    return mean_stddev_box_coder.MeanStddevBoxCoder()
  if box_coder_config.WhichOneof('box_coder_oneof') == 'square_box_coder':
    return square_box_coder.SquareBoxCoder(scale_factors=[
        box_coder_config.square_box_coder.y_scale,
        box_coder_config.square_box_coder.x_scale,
        box_coder_config.square_box_coder.length_scale
    ])
  raise ValueError('Empty box coder.') 
Example #30
Source File: box_coder_builder_test.py    From HereIsWally with MIT License 5 votes vote down vote up
def test_build_square_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      square_box_coder {
        y_scale: 6.0
        x_scale: 3.0
        length_scale: 7.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(
        isinstance(box_coder_object, square_box_coder.SquareBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0])