(bbox_ref, bboxes, name=None)
Compute jaccard score between a reference box and a collection
    of bounding boxes.

    Args:
      bbox_ref: (N, 4) or (4,) Tensor with reference bounding box(es).
      bboxes: (N, 4) Tensor, collection of bounding boxes.
    Return:
      (N,) Tensor with Jaccard scores.
Compute jaccard score between a reference box and a collection
    of bounding boxes.
Compute jaccard score between a reference box and a collection of bounding boxes .
def bboxes_jaccard(bbox_ref, bboxes, name=None):
    """Compute jaccard score between a reference box and a collection
    of bounding boxes.

    Args:
      bbox_ref: (N, 4) or (4,) Tensor with reference bounding box(es).
      bboxes: (N, 4) Tensor, collection of bounding boxes.
    Return:
      (N,) Tensor with Jaccard scores.
    """
    with tf.name_scope(name, 'bboxes_jaccard'):
        # Should be more efficient to first transpose.
        bboxes = tf.transpose(bboxes)
        #print(bboxes.get_shape().as_list())
        bbox_ref = tf.transpose(bbox_ref)
        # Intersection bbox and volume.
        int_ymin = tf.maximum(bboxes[0], bbox_ref[0])
        int_xmin = tf.maximum(bboxes[1], bbox_ref[1])
        int_ymax = tf.minimum(bboxes[2], bbox_ref[2])
        int_xmax = tf.minimum(bboxes[3], bbox_ref[3])
        h = tf.maximum(int_ymax - int_ymin, 0.)
        w = tf.maximum(int_xmax - int_xmin, 0.)
        # Volumes.
        inter_vol = h * w
        union_vol = -inter_vol \
            + (bboxes[2] - bboxes[0]) * (bboxes[3] - bboxes[1]) \
            + (bbox_ref[2] - bbox_ref[0]) * (bbox_ref[3] - bbox_ref[1])
        jaccard = safe_divide(inter_vol, union_vol)
        return jaccard
def bboxes_jaccard ( bbox_ref , bboxes , name = None ) : with tf . name_scope ( name , 'bboxes_jaccard' ) : # Should be more efficient to first transpose. bboxes = tf . transpose ( bboxes ) #print(bboxes.get_shape().as_list()) bbox_ref = tf . transpose ( bbox_ref ) # Intersection bbox and volume. int_ymin = tf . maximum ( bboxes [ 0 ] , bbox_ref [ 0 ] ) int_xmin = tf . maximum ( bboxes [ 1 ] , bbox_ref [ 1 ] ) int_ymax = tf . minimum ( bboxes [ 2 ] , bbox_ref [ 2 ] ) int_xmax = tf . minimum ( bboxes [ 3 ] , bbox_ref [ 3 ] ) h = tf . maximum ( int_ymax - int_ymin , 0. ) w = tf . maximum ( int_xmax - int_xmin , 0. ) # Volumes. inter_vol = h * w union_vol = - inter_vol + ( bboxes [ 2 ] - bboxes [ 0 ] ) * ( bboxes [ 3 ] - bboxes [ 1 ] ) + ( bbox_ref [ 2 ] - bbox_ref [ 0 ] ) * ( bbox_ref [ 3 ] - bbox_ref [ 1 ] ) jaccard = safe_divide ( inter_vol , union_vol ) return jaccard