From 525e091431b6e6661f5ec6b61b83857791aff441 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" <gardener@tensorflow.org> Date: Wed, 26 Feb 2020 16:02:42 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 297466825 Change-Id: I8f4990d992478b4783c00119e4c1a23cff699d81 --- .../core/kernels/non_max_suppression_op.cc | 23 ------------------- .../kernels/non_max_suppression_op_test.cc | 2 +- tensorflow/python/ops/image_ops_test.py | 2 +- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/tensorflow/core/kernels/non_max_suppression_op.cc b/tensorflow/core/kernels/non_max_suppression_op.cc index c125c673928..20ae3a2e0d0 100644 --- a/tensorflow/core/kernels/non_max_suppression_op.cc +++ b/tensorflow/core/kernels/non_max_suppression_op.cc @@ -39,17 +39,6 @@ namespace { typedef Eigen::ThreadPoolDevice CPUDevice; -template <typename T> -bool CheckBoxesCoordinates(const Tensor& boxes, int num_boxes) { - typename TTypes<T, 2>::ConstTensor boxes_data = boxes.tensor<T, 2>(); - for (int i = 0; i < num_boxes; ++i) { - if (boxes_data(i, 0) == boxes_data(i, 2) || - boxes_data(i, 1) == boxes_data(i, 3)) - return false; - } - return true; -} - static inline void CheckScoreSizes(OpKernelContext* context, int num_boxes, const Tensor& scores) { // The shape of 'scores' is [num_boxes] @@ -605,9 +594,6 @@ class NonMaxSuppressionOp : public OpKernel { int num_boxes = 0; ParseAndCheckBoxSizes(context, boxes, &num_boxes); CheckScoreSizes(context, num_boxes, scores); - OP_REQUIRES( - context, CheckBoxesCoordinates<float>(boxes, num_boxes), - errors::InvalidArgument("Boxes are empty (x1 == x2 or y1 == y2)")); if (!context->status().ok()) { return; } @@ -655,9 +641,6 @@ class NonMaxSuppressionV2Op : public OpKernel { int num_boxes = 0; ParseAndCheckBoxSizes(context, boxes, &num_boxes); CheckScoreSizes(context, num_boxes, scores); - OP_REQUIRES( - context, CheckBoxesCoordinates<T>(boxes, num_boxes), - errors::InvalidArgument("Boxes are empty (x1 == x2 or y1 == y2)")); if (!context->status().ok()) { return; } @@ -709,9 +692,6 @@ class NonMaxSuppressionV3Op : public OpKernel { int num_boxes = 0; ParseAndCheckBoxSizes(context, boxes, &num_boxes); CheckScoreSizes(context, num_boxes, scores); - OP_REQUIRES( - context, CheckBoxesCoordinates<T>(boxes, num_boxes), - errors::InvalidArgument("Boxes are empty (x1 == x2 or y1 == y2)")); if (!context->status().ok()) { return; } @@ -766,9 +746,6 @@ class NonMaxSuppressionV4Op : public OpKernel { int num_boxes = 0; ParseAndCheckBoxSizes(context, boxes, &num_boxes); CheckScoreSizes(context, num_boxes, scores); - OP_REQUIRES( - context, CheckBoxesCoordinates<T>(boxes, num_boxes), - errors::InvalidArgument("Boxes are empty (x1 == x2 or y1 == y2)")); if (!context->status().ok()) { return; } diff --git a/tensorflow/core/kernels/non_max_suppression_op_test.cc b/tensorflow/core/kernels/non_max_suppression_op_test.cc index 59d5c5e8148..115f7902478 100644 --- a/tensorflow/core/kernels/non_max_suppression_op_test.cc +++ b/tensorflow/core/kernels/non_max_suppression_op_test.cc @@ -106,7 +106,7 @@ TEST_F(NonMaxSuppressionOpTest, TestSelectWithNegativeScores) { TEST_F(NonMaxSuppressionOpTest, TestFirstBoxDegenerate) { MakeOp(.5); AddInputFromArray<float>(TensorShape({3, 4}), - {0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3}); + {0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 3, 3}); AddInputFromArray<float>(TensorShape({3}), {.9f, .75f, .6f}); AddInputFromArray<int>(TensorShape({}), {3}); TF_ASSERT_OK(RunOpKernel()); diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py index 3b7f75b141a..f4c0f6926b1 100644 --- a/tensorflow/python/ops/image_ops_test.py +++ b/tensorflow/python/ops/image_ops_test.py @@ -4598,7 +4598,7 @@ class NonMaxSuppressionPaddedTest(test_util.TensorFlowTestCase): "non_max_suppression with dynamic output shape unsupported.") def testSelectFromContinuousOverLap(self): boxes_np = [[0, 0, 1, 1], [0, 0.2, 1, 1.2], [0, 0.4, 1, 1.4], - [0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 3]] + [0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 2]] scores_np = [0.9, 0.75, 0.6, 0.5, 0.4, 0.3] max_output_size_np = 3 iou_threshold_np = 0.5