(labels, bboxes, margins=[0., 0., 0., 0.],
                         scope=None)
Filter out bounding boxes whose center are not in
    the rectangle [0, 0, 1, 1] + margins. The margin Tensor
    can be used to enforce or loosen this condition.

    Return:
      labels, bboxes: Filtered elements.
Filter out bounding boxes whose center are not in
    the rectangle [0, 0, 1, 1] + margins. The margin Tensor
    can be used to enforce or loosen this condition.
Filter out bounding boxes whose center are not in the rectangle [ 0 0 1 1 ] + margins . The margin Tensor can be used to enforce or loosen this condition .
def bboxes_filter_center(labels, bboxes, margins=[0., 0., 0., 0.],
                         scope=None):
    """Filter out bounding boxes whose center are not in
    the rectangle [0, 0, 1, 1] + margins. The margin Tensor
    can be used to enforce or loosen this condition.

    Return:
      labels, bboxes: Filtered elements.
    """
    with tf.name_scope(scope, 'bboxes_filter', [labels, bboxes]):
        cy = (bboxes[:, 0] + bboxes[:, 2]) / 2.
        cx = (bboxes[:, 1] + bboxes[:, 3]) / 2.
        mask = tf.greater(cy, margins[0])
        mask = tf.logical_and(mask, tf.greater(cx, margins[1]))
        mask = tf.logical_and(mask, tf.less(cx, 1. + margins[2]))
        mask = tf.logical_and(mask, tf.less(cx, 1. + margins[3]))
        # Boolean masking...
        labels = tf.boolean_mask(labels, mask)
        bboxes = tf.boolean_mask(bboxes, mask)
        return labels, bboxes
def bboxes_filter_center ( labels , bboxes , margins = [ 0. , 0. , 0. , 0. ] , scope = None ) : with tf . name_scope ( scope , 'bboxes_filter' , [ labels , bboxes ] ) : cy = ( bboxes [ : , 0 ] + bboxes [ : , 2 ] ) / 2. cx = ( bboxes [ : , 1 ] + bboxes [ : , 3 ] ) / 2. mask = tf . greater ( cy , margins [ 0 ] ) mask = tf . logical_and ( mask , tf . greater ( cx , margins [ 1 ] ) ) mask = tf . logical_and ( mask , tf . less ( cx , 1. + margins [ 2 ] ) ) mask = tf . logical_and ( mask , tf . less ( cx , 1. + margins [ 3 ] ) ) # Boolean masking... labels = tf . boolean_mask ( labels , mask ) bboxes = tf . boolean_mask ( bboxes , mask ) return labels , bboxes