Python object_detection.core.box_list_ops.area() Examples
The following are 30
code examples of object_detection.core.box_list_ops.area().
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.core.box_list_ops
, or try the search function
.
Example #1
Source File: box_list_ops_test.py From moveo_ros with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #2
Source File: box_list_ops_test.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #3
Source File: box_list_ops_test.py From yolo_v2 with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #4
Source File: box_list_ops_test.py From HereIsWally with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #5
Source File: box_list_ops_test.py From garbage-object-detection-tensorflow with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #6
Source File: box_list_ops_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') if ops._USE_C_API: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'weights') else: with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #7
Source File: box_list_ops_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #8
Source File: box_list_ops_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'weights')
Example #9
Source File: box_list_ops_test.py From object_detector_app with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #10
Source File: box_list_ops_test.py From DOTA_models with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #11
Source File: box_list_ops_test.py From Hands-On-Machine-Learning-with-OpenCV-4 with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #12
Source File: box_list_ops_test.py From tensorflow with BSD 2-Clause "Simplified" License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #13
Source File: box_list_ops_test.py From Gun-Detector with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') if ops._USE_C_API: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'weights') else: with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #14
Source File: box_list_ops_test.py From ros_tensorflow with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') if ops._USE_C_API: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'weights') else: with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #15
Source File: box_list_ops_test.py From BMW-TensorFlow-Training-GUI with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') if ops._USE_C_API: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'weights') else: with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #16
Source File: box_list_ops_test.py From hands-detection with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #17
Source File: box_list_ops_test.py From object_detection_kitti with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #18
Source File: box_list_ops_test.py From MBMD with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #19
Source File: box_list_ops_test.py From Elphas with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #20
Source File: box_list_ops_test.py From object_detection_with_tensorflow with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #21
Source File: box_list_ops_test.py From object_detection_with_tensorflow with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #22
Source File: box_list_ops_test.py From AniSeg with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #23
Source File: box_list_ops_test.py From MAX-Object-Detector with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'weights')
Example #24
Source File: box_list_ops_test.py From Accident-Detection-on-Indian-Roads with GNU Affero General Public License v3.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') if ops._USE_C_API: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'weights') else: with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #25
Source File: box_list_ops_test.py From g-tensorflow-models with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'weights')
Example #26
Source File: box_list_ops_test.py From models with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([[.1, .2]], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'weights')
Example #27
Source File: multiple_grid_anchor_generator.py From motion-rcnn with MIT License | 6 votes |
def assign_boxes_to_layers(self, absolute_boxes): """Assigns boxes to feature pyramid layers. Args: absolute_boxes: A float32 tensor with shape [batch_size, num_proposals, box_code_size] containing boxes in absolute coordinates. Returns: layer_indices: A int32 tensor of shape [N], ranging from lowest resolution (0) to highest (num_resolutions - 1) """ def log2(x): numerator = tf.log(x) denominator = tf.log(tf.constant(2, dtype=numerator.dtype)) return numerator / denominator min_scale = self._base_anchor_size[0] * min(self._pyramid_scales) box_scales = tf.sqrt(box_list_ops.area(box_list.BoxList(absolute_boxes))) max_k = len(self._pyramid_scales) - 1 k = tf.round(log2(box_scales / min_scale)) k = tf.minimum(tf.maximum(k, 0), max_k) return max_k - tf.to_int32(k)
Example #28
Source File: box_list_ops_test.py From motion-rcnn with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #29
Source File: box_list_ops_test.py From mtl-ssl with Apache License 2.0 | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.test_session() as sess: with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError, 'Incorrect field size'): sess.run(box_list_ops.sort_by_field(boxes, 'weights').get())
Example #30
Source File: box_list_ops_test.py From multilabel-image-classification-tensorflow with MIT License | 6 votes |
def test_sort_by_field_invalid_inputs(self): corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]) misc = tf.constant([[.95, .9], [.5, .3]], tf.float32) weights = tf.constant([.1, .2], tf.float32) boxes = box_list.BoxList(corners) boxes.add_field('misc', misc) boxes.add_field('weights', weights) with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'area') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'misc') with self.assertRaises(ValueError): box_list_ops.sort_by_field(boxes, 'weights')