code: def filter_boxes(
      box_xywh,
      scores,
      score_threshold=0.4,
      input_shape=tf.constant([416, 416]),
  ):
      scores_max = tf.math.reduce_max(scores, axis=-1)
  
      mask = scores_max >= score_threshold
      class_boxes = tf.boolean_mask(box_xywh, mask)
      pred_conf = tf.boolean_mask(scores, mask)
      class_boxes = tf.reshape(
          class_boxes,
          [tf.shape(scores)[0], -1, tf.shape(class_boxes)[-1]],
      )
      pred_conf = tf.reshape(
          pred_conf, [tf.shape(scores)[0], -1, tf.shape(pred_conf)[-1]]
      )
  
      box_xy, box_wh = tf.split(class_boxes, (2, 2), axis=-1)
  
      input_shape = tf.cast(input_shape, dtype=tf.float32)
      box_yx = box_xy[..., ::-1]
      box_hw = box_wh[..., ::-1]
  
      box_mins = (box_yx - (box_hw / 2.0)) / input_shape
      box_maxes = (box_yx + (box_hw / 2.0)) / input_shape
      boxes = tf.concat(
          [
              box_mins[..., 0:1],  # y_min
              box_mins[..., 1:2],  # x_min
              box_maxes[..., 0:1],  # y_max
              box_maxes[..., 1:2],  # x_max
          ],
          axis=-1,
      )
      # return tf.concat([boxes, pred_conf], axis=-1)
      return (boxes, pred_conf)
  
file_path: TensorLayer/tensorlayer/app/computer_vision_object_detection/common.py
imports: import tensorflow
  import colorsys, random, cv2
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: filter_boxes(box_xywh, scores, score_threshold, input_shape) and returns: boxes,  pred_conf