def yolo5_boxes_and_scores(feats, anchors, num_classes, input_shape, image_shape, scale_x_y):
    '''Process Conv layer output'''
    box_xy, box_wh, box_confidence, box_class_probs = yolo5_decode(feats,
        anchors, num_classes, input_shape, scale_x_y=scale_x_y)
    boxes = yolo3_correct_boxes(box_xy, box_wh, input_shape, image_shape)
    boxes = K.reshape(boxes, [-1, 4])
    box_scores = box_confidence * box_class_probs
    box_scores = K.reshape(box_scores, [-1, num_classes])
    return boxes, box_scores
def yolo5_boxes_and_scores(feats, anchors, num_classes, input_shape,
                           image_shape, scale_x_y):
    '''Process Conv layer output'''
    box_xy, box_wh, box_confidence, box_class_probs = yolo5_decode(
        feats, anchors, num_classes, input_shape, scale_x_y=scale_x_y)
    boxes = yolo3_correct_boxes(box_xy, box_wh, input_shape, image_shape)
    boxes = K.reshape(boxes, [-1, 4])
    # check if only 1 class for different score
    box_scores = tf.cond(
        K.equal(K.constant(value=num_classes, dtype='int32'), 1),
        lambda: box_confidence, lambda: box_confidence * box_class_probs)
    box_scores = K.reshape(box_scores, [-1, num_classes])
    return boxes, box_scores
def batched_yolo5_boxes_and_scores(feats, anchors, num_classes, input_shape, image_shape, scale_x_y):
    '''Process Conv layer output'''
    box_xy, box_wh, box_confidence, box_class_probs = yolo5_decode(feats,
        anchors, num_classes, input_shape, scale_x_y=scale_x_y)

    num_anchors = len(anchors)
    grid_shape = K.shape(feats)[1:3] # height, width
    total_anchor_num = grid_shape[0] * grid_shape[1] * num_anchors

    boxes = yolo3_correct_boxes(box_xy, box_wh, input_shape, image_shape)
    boxes = K.reshape(boxes, [-1, total_anchor_num, 4])
    box_scores = box_confidence * box_class_probs
    box_scores = K.reshape(box_scores, [-1, total_anchor_num, num_classes])
    return boxes, box_scores
def batched_yolo5_boxes_and_scores(feats, anchors, num_classes, input_shape,
                                   image_shape, scale_x_y):
    '''Process Conv layer output'''
    box_xy, box_wh, box_confidence, box_class_probs = yolo5_decode(
        feats, anchors, num_classes, input_shape, scale_x_y=scale_x_y)

    num_anchors = len(anchors)
    grid_shape = K.shape(feats)[1:3]  # height, width
    total_anchor_num = grid_shape[0] * grid_shape[1] * num_anchors

    boxes = yolo3_correct_boxes(box_xy, box_wh, input_shape, image_shape)
    boxes = K.reshape(boxes, [-1, total_anchor_num, 4])
    # check if only 1 class for different score
    box_scores = tf.cond(
        K.equal(K.constant(value=num_classes, dtype='int32'), 1),
        lambda: box_confidence, lambda: box_confidence * box_class_probs)
    box_scores = K.reshape(box_scores, [-1, total_anchor_num, num_classes])
    return boxes, box_scores