(labels, bboxes,
                          threshold=0.5, assign_negative=False,
                          scope=None)
Filter out bounding boxes based on (relative )overlap with reference
    box [0, 0, 1, 1].  Remove completely bounding boxes, or assign negative
    labels to the one outside (useful for latter processing...).

    Return:
      labels, bboxes: Filtered (or newly assigned) elements.
Filter out bounding boxes based on (relative )overlap with reference
    box [0, 0, 1, 1].  Remove completely bounding boxes, or assign negative
    labels to the one outside (useful for latter processing...).
Filter out bounding boxes based on ( relative ) overlap with reference box [ 0 0 1 1 ] . Remove completely bounding boxes or assign negative labels to the one outside ( useful for latter processing ... ) .
def bboxes_filter_overlap(labels, bboxes,
                          threshold=0.5, assign_negative=False,
                          scope=None):
    """Filter out bounding boxes based on (relative )overlap with reference
    box [0, 0, 1, 1].  Remove completely bounding boxes, or assign negative
    labels to the one outside (useful for latter processing...).

    Return:
      labels, bboxes: Filtered (or newly assigned) elements.
    """
    with tf.name_scope(scope, 'bboxes_filter', [labels, bboxes]):
        scores = bboxes_intersection(tf.constant([0, 0, 1, 1], bboxes.dtype),
                                     bboxes)
        # always keep al least one
        max_intersection = tf.reduce_max(scores)
        max_intersection_mask = tf.equal(scores, max_intersection)

        mask = tf.logical_or(scores > threshold, max_intersection_mask)

        if assign_negative:
            labels = tf.where(mask, labels, -labels)
            # bboxes = tf.where(mask, bboxes, bboxes)
        else:
            labels = tf.boolean_mask(labels, mask)
            bboxes = tf.boolean_mask(bboxes, mask)
        return labels, bboxes
def bboxes_filter_overlap ( labels , bboxes , threshold = 0.5 , assign_negative = False , scope = None ) : with tf . name_scope ( scope , 'bboxes_filter' , [ labels , bboxes ] ) : scores = bboxes_intersection ( tf . constant ( [ 0 , 0 , 1 , 1 ] , bboxes . dtype ) , bboxes ) # always keep al least one max_intersection = tf . reduce_max ( scores ) max_intersection_mask = tf . equal ( scores , max_intersection ) mask = tf . logical_or ( scores > threshold , max_intersection_mask ) if assign_negative : labels = tf . where ( mask , labels , - labels ) # bboxes = tf.where(mask, bboxes, bboxes) else : labels = tf . boolean_mask ( labels , mask ) bboxes = tf . boolean_mask ( bboxes , mask ) return labels , bboxes