Пример #1
0
 def test_ioaworks_on_empty_inputs(self):
     corners1 = tf.constant([[4.0, 3.0, 7.0, 5.0], [5.0, 6.0, 10.0, 7.0]])
     corners2 = tf.constant([[3.0, 4.0, 6.0, 8.0], [14.0, 14.0, 15.0, 15.0],
                             [0.0, 0.0, 20.0, 20.0]])
     boxes1 = box_list.BoxList(corners1)
     boxes2 = box_list.BoxList(corners2)
     boxes_empty = box_list.BoxList(tf.zeros((0, 4)))
     ioa_empty_1 = box_list_ops.ioa(boxes1, boxes_empty)
     ioa_empty_2 = box_list_ops.ioa(boxes_empty, boxes2)
     ioa_empty_3 = box_list_ops.ioa(boxes_empty, boxes_empty)
     with self.test_session() as sess:
         ioa_output_1, ioa_output_2, ioa_output_3 = sess.run(
             [ioa_empty_1, ioa_empty_2, ioa_empty_3])
         self.assertAllEqual(ioa_output_1.shape, (2, 0))
         self.assertAllEqual(ioa_output_2.shape, (0, 3))
         self.assertAllEqual(ioa_output_3.shape, (0, 0))
Пример #2
0
 def test_ioa(self):
   corners1 = tf.constant([[4.0, 3.0, 7.0, 5.0], [5.0, 6.0, 10.0, 7.0]])
   corners2 = tf.constant([[3.0, 4.0, 6.0, 8.0], [14.0, 14.0, 15.0, 15.0],
                           [0.0, 0.0, 20.0, 20.0]])
   exp_output_1 = [[2.0 / 12.0, 0, 6.0 / 400.0],
                   [1.0 / 12.0, 0.0, 5.0 / 400.0]]
   exp_output_2 = [[2.0 / 6.0, 1.0 / 5.0],
                   [0, 0],
                   [6.0 / 6.0, 5.0 / 5.0]]
   boxes1 = box_list.BoxList(corners1)
   boxes2 = box_list.BoxList(corners2)
   ioa_1 = box_list_ops.ioa(boxes1, boxes2)
   ioa_2 = box_list_ops.ioa(boxes2, boxes1)
   with self.test_session() as sess:
     ioa_output_1, ioa_output_2 = sess.run([ioa_1, ioa_2])
     self.assertAllClose(ioa_output_1, exp_output_1)
     self.assertAllClose(ioa_output_2, exp_output_2)
    def _compare(self, boxlist1, boxlist2):
        """Compute pairwise IOA similarity between the two BoxLists.

    Args:
      boxlist1: BoxList holding N boxes.
      boxlist2: BoxList holding M boxes.

    Returns:
      A tensor with shape [N, M] representing pairwise IOA scores.
    """
        return box_list_ops.ioa(boxlist1, boxlist2)