(scores, labels, bboxes, min_size_ratio, image_shape, net_input_shape)
return tf.boolean_mask(scores, keep_mask), tf.boolean_mask(labels, keep_mask), tf.boolean_mask(bboxes, keep_mask)
Only keep boxes with both sides >= min_size and center within the image.
        min_size_ratio is the ratio relative to net input shape
Only keep boxes with both sides >= min_size and center within the image.
        min_size_ratio is the ratio relative to net input shape
Only keep boxes with both sides > = min_size and center within the image . min_size_ratio is the ratio relative to net input shape
def filter_boxes(scores, labels, bboxes, min_size_ratio, image_shape, net_input_shape):
        """Only keep boxes with both sides >= min_size and center within the image.
        min_size_ratio is the ratio relative to net input shape
        """
        # Scale min_size to match image scale
        min_size = tf.maximum(0.0001, min_size_ratio * tf.sqrt(tf.cast(image_shape[0] * image_shape[1], tf.float32) / (net_input_shape[0] * net_input_shape[1])))

        ymin = bboxes[:, 0]
        xmin = bboxes[:, 1]

        ws = bboxes[:, 3] - xmin
        hs = bboxes[:, 2] - ymin

        x_ctr = xmin + ws / 2.
        y_ctr = ymin + hs / 2.

        keep_mask = tf.logical_and(tf.greater(ws, min_size), tf.greater(hs, min_size))
        keep_mask = tf.logical_and(keep_mask, tf.greater(x_ctr, 0.))
        keep_mask = tf.logical_and(keep_mask, tf.greater(y_ctr, 0.))
        keep_mask = tf.logical_and(keep_mask, tf.less(x_ctr, 1.))
        keep_mask = tf.logical_and(keep_mask, tf.less(y_ctr, 1.))

        return tf.boolean_mask(scores, keep_mask), tf.boolean_mask(labels, keep_mask), tf.boolean_mask(bboxes, keep_mask)
def filter_boxes ( scores , labels , bboxes , min_size_ratio , image_shape , net_input_shape ) : # Scale min_size to match image scale min_size = tf . maximum ( 0.0001 , min_size_ratio * tf . sqrt ( tf . cast ( image_shape [ 0 ] * image_shape [ 1 ] , tf . float32 ) / ( net_input_shape [ 0 ] * net_input_shape [ 1 ] ) ) ) ymin = bboxes [ : , 0 ] xmin = bboxes [ : , 1 ] ws = bboxes [ : , 3 ] - xmin hs = bboxes [ : , 2 ] - ymin x_ctr = xmin + ws / 2. y_ctr = ymin + hs / 2. keep_mask = tf . logical_and ( tf . greater ( ws , min_size ) , tf . greater ( hs , min_size ) ) keep_mask = tf . logical_and ( keep_mask , tf . greater ( x_ctr , 0. ) ) keep_mask = tf . logical_and ( keep_mask , tf . greater ( y_ctr , 0. ) ) keep_mask = tf . logical_and ( keep_mask , tf . less ( x_ctr , 1. ) ) keep_mask = tf . logical_and ( keep_mask , tf . less ( y_ctr , 1. ) ) return tf . boolean_mask ( scores , keep_mask ) , tf . boolean_mask ( labels , keep_mask ) , tf . boolean_mask ( bboxes , keep_mask )