Ejemplo n.º 1
0
 def graph_fn():
   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)
   ioa_1 = box_list_ops.ioa(boxes1, boxes2)
   ioa_2 = box_list_ops.ioa(boxes2, boxes1)
   return ioa_1, ioa_2
Ejemplo n.º 2
0
 def graph_fn():
   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)
   return ioa_empty_1, ioa_empty_2, ioa_empty_3
Ejemplo n.º 3
0
    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 tf.scalar_mul(self._anchor_related_weight, box_list_ops.ioa(boxlist1, boxlist2)) + \
               tf.scalar_mul(self._ground_truth_related_weight, tf.transpose(box_list_ops.ioa(boxlist2, boxlist1)))
 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 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))
Ejemplo n.º 6
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))
Ejemplo n.º 7
0
    def _compare(self, boxlist1, boxlist2):
        reserved_ioa = tf.transpose(box_list_ops.ioa(boxlist2, boxlist1))
        neg_sq_center_dist = -1 * box_list_ops.sq_center_dist(
            boxlist1, boxlist2)

        return tf.multiply(tf.scalar_mul(2, tf.sigmoid(neg_sq_center_dist)),
                           reserved_ioa)
Ejemplo n.º 8
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)
Ejemplo n.º 10
0
    def _get_cutout_boxes_mask(self, object_boxes, cutout_box):
        cutout_box_list = box_list.BoxList(cutout_box[tf.newaxis, ...])

        object_boxes_list = box_list.BoxList(object_boxes)
        object_boxes_occlusions = box_list_ops.ioa(cutout_box_list,
                                                   object_boxes_list)[0]

        boxes_mask = tf.less_equal(object_boxes_occlusions, self.max_occlusion)
        return boxes_mask
Ejemplo n.º 11
0
  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)