Python object_detection.box_coders.keypoint_box_coder.KeypointBoxCoder() Examples
The following are 30
code examples of object_detection.box_coders.keypoint_box_coder.KeypointBoxCoder().
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.box_coders.keypoint_box_coder
, or try the search function
.
Example #1
Source File: keypoint_box_coder_test.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
def test_get_correct_relative_codes_after_encoding(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] expected_rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #2
Source File: keypoint_box_coder_test.py From Hands-On-Machine-Learning-with-OpenCV-4 with MIT License | 6 votes |
def test_get_correct_boxes_after_decoding_with_scaling(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] scale_factors = [2, 3, 4, 5] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #3
Source File: keypoint_box_coder_test.py From Hands-On-Machine-Learning-with-OpenCV-4 with MIT License | 6 votes |
def test_get_correct_boxes_after_decoding(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #4
Source File: box_coder_builder_test.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
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: keypoint_box_coder_test.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
def test_get_correct_boxes_after_decoding_with_scaling(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] scale_factors = [2, 3, 4, 5] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #6
Source File: keypoint_box_coder_test.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
def test_get_correct_boxes_after_decoding(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #7
Source File: keypoint_box_coder_test.py From Hands-On-Machine-Learning-with-OpenCV-4 with MIT License | 6 votes |
def test_get_correct_relative_codes_after_encoding(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] expected_rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #8
Source File: keypoint_box_coder_test.py From tensorflow with BSD 2-Clause "Simplified" License | 6 votes |
def test_get_correct_relative_codes_after_encoding_with_scaling(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] scale_factors = [2, 3, 4, 5] expected_rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #9
Source File: keypoint_box_coder_test.py From tensorflow with BSD 2-Clause "Simplified" License | 6 votes |
def test_get_correct_boxes_after_decoding(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #10
Source File: keypoint_box_coder_test.py From tensorflow with BSD 2-Clause "Simplified" License | 6 votes |
def test_get_correct_boxes_after_decoding_with_scaling(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] scale_factors = [2, 3, 4, 5] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #11
Source File: keypoint_box_coder_test.py From Gun-Detector with Apache License 2.0 | 6 votes |
def test_get_correct_relative_codes_after_encoding(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] expected_rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #12
Source File: keypoint_box_coder_test.py From Gun-Detector with Apache License 2.0 | 6 votes |
def test_get_correct_relative_codes_after_encoding_with_scaling(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] scale_factors = [2, 3, 4, 5] expected_rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #13
Source File: keypoint_box_coder_test.py From Gun-Detector with Apache License 2.0 | 6 votes |
def test_get_correct_boxes_after_decoding(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #14
Source File: keypoint_box_coder_test.py From Gun-Detector with Apache License 2.0 | 6 votes |
def test_get_correct_boxes_after_decoding_with_scaling(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] scale_factors = [2, 3, 4, 5] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #15
Source File: keypoint_box_coder_test.py From tensorflow with BSD 2-Clause "Simplified" License | 6 votes |
def test_get_correct_relative_codes_after_encoding(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] expected_rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #16
Source File: keypoint_box_coder_test.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
def test_get_correct_relative_codes_after_encoding_with_scaling(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] scale_factors = [2, 3, 4, 5] expected_rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #17
Source File: box_coder_builder_test.py From yolo_v2 with Apache License 2.0 | 6 votes |
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 #18
Source File: keypoint_box_coder_test.py From yolo_v2 with Apache License 2.0 | 6 votes |
def test_get_correct_boxes_after_decoding_with_scaling(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] scale_factors = [2, 3, 4, 5] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #19
Source File: keypoint_box_coder_test.py From yolo_v2 with Apache License 2.0 | 6 votes |
def test_get_correct_boxes_after_decoding(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #20
Source File: keypoint_box_coder_test.py From yolo_v2 with Apache License 2.0 | 6 votes |
def test_get_correct_relative_codes_after_encoding_with_scaling(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] scale_factors = [2, 3, 4, 5] expected_rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #21
Source File: keypoint_box_coder_test.py From yolo_v2 with Apache License 2.0 | 6 votes |
def test_get_correct_relative_codes_after_encoding(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] expected_rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #22
Source File: keypoint_box_coder_test.py From HereIsWally with MIT License | 6 votes |
def test_get_correct_boxes_after_decoding_with_scaling(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] scale_factors = [2, 3, 4, 5] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #23
Source File: keypoint_box_coder_test.py From HereIsWally with MIT License | 6 votes |
def test_get_correct_boxes_after_decoding(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #24
Source File: keypoint_box_coder_test.py From HereIsWally with MIT License | 6 votes |
def test_get_correct_relative_codes_after_encoding_with_scaling(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] scale_factors = [2, 3, 4, 5] expected_rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #25
Source File: keypoint_box_coder_test.py From HereIsWally with MIT License | 6 votes |
def test_get_correct_relative_codes_after_encoding(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] expected_rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #26
Source File: keypoint_box_coder_test.py From garbage-object-detection-tensorflow with MIT License | 6 votes |
def test_get_correct_boxes_after_decoding_with_scaling(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] scale_factors = [2, 3, 4, 5] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #27
Source File: keypoint_box_coder_test.py From garbage-object-detection-tensorflow with MIT License | 6 votes |
def test_get_correct_boxes_after_decoding(self): anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] expected_boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] expected_keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(expected_keypoints[0]) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) boxes = coder.decode(rel_codes, anchors) with self.test_session() as sess: boxes_out, keypoints_out = sess.run( [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)]) self.assertAllClose(boxes_out, expected_boxes) self.assertAllClose(keypoints_out, expected_keypoints)
Example #28
Source File: keypoint_box_coder_test.py From garbage-object-detection-tensorflow with MIT License | 6 votes |
def test_get_correct_relative_codes_after_encoding_with_scaling(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] scale_factors = [2, 3, 4, 5] expected_rel_codes = [ [-1., -1.25, -1.62186, -0.911608, -1.0, -1.5, -1.666667, 0.], [-0.166667, -0.666667, -2.772588, -5.493062, 0.333333, -0.5, -0.666667, -0.166667] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder( num_keypoints, scale_factors=scale_factors) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #29
Source File: keypoint_box_coder_test.py From garbage-object-detection-tensorflow with MIT License | 6 votes |
def test_get_correct_relative_codes_after_encoding(self): boxes = [[10., 10., 20., 15.], [0.2, 0.1, 0.5, 0.4]] keypoints = [[[15., 12.], [10., 15.]], [[0.5, 0.3], [0.2, 0.4]]] num_keypoints = len(keypoints[0]) anchors = [[15., 12., 30., 18.], [0.1, 0.0, 0.7, 0.9]] expected_rel_codes = [ [-0.5, -0.416666, -0.405465, -0.182321, -0.5, -0.5, -0.833333, 0.], [-0.083333, -0.222222, -0.693147, -1.098612, 0.166667, -0.166667, -0.333333, -0.055556] ] boxes = box_list.BoxList(tf.constant(boxes)) boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints)) anchors = box_list.BoxList(tf.constant(anchors)) coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints) rel_codes = coder.encode(boxes, anchors) with self.test_session() as sess: rel_codes_out, = sess.run([rel_codes]) self.assertAllClose(rel_codes_out, expected_rel_codes)
Example #30
Source File: box_coder_builder_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
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])