(scores, bboxes, top_k=100, scope=None)
Sort bounding boxes by decreasing order and keep only the top_k.
    If inputs are dictionnaries, assume every key is a different class.
    Assume a batch-type input.

    Args:
      scores: Batch x N Tensor/Dictionary containing float scores.
      bboxes: Batch x N x 4 Tensor/Dictionary containing boxes coordinates.
      top_k: Top_k boxes to keep.
    Return:
      scores, bboxes: Sorted Tensors/Dictionaries of shape Batch x Top_k x 1|4.
Sort bounding boxes by decreasing order and keep only the top_k.
    If inputs are dictionnaries, assume every key is a different class.
    Assume a batch-type input.
Sort bounding boxes by decreasing order and keep only the top_k . If inputs are dictionnaries assume every key is a different class . Assume a batch - type input .
def bboxes_sort(scores, bboxes, top_k=100, scope=None):
    """Sort bounding boxes by decreasing order and keep only the top_k.
    If inputs are dictionnaries, assume every key is a different class.
    Assume a batch-type input.

    Args:
      scores: Batch x N Tensor/Dictionary containing float scores.
      bboxes: Batch x N x 4 Tensor/Dictionary containing boxes coordinates.
      top_k: Top_k boxes to keep.
    Return:
      scores, bboxes: Sorted Tensors/Dictionaries of shape Batch x Top_k x 1|4.
    """
    # Dictionaries as inputs.
    if isinstance(scores, dict) or isinstance(bboxes, dict):
        with tf.name_scope(scope, 'bboxes_sort_dict'):
            d_scores = {}
            d_bboxes = {}
            for c in scores.keys():
                s, b = bboxes_sort(scores[c], bboxes[c], top_k=tf.minimum(tf.shape(scores[c])[0], top_k))
                d_scores[c] = s
                d_bboxes[c] = b
            return d_scores, d_bboxes

    # Tensors inputs.
    with tf.name_scope(scope, 'bboxes_sort', [scores, bboxes]):
        # Sort scores...
        scores, idxes = tf.nn.top_k(scores, k=top_k, sorted=True)
        #return scores, tf.gather(bboxes, idxes)
        return pad_axis(scores, 0, top_k, axis=0), pad_axis(tf.gather(bboxes, idxes), 0, top_k, axis=0)
def bboxes_sort ( scores , bboxes , top_k = 100 , scope = None ) : # Dictionaries as inputs. if isinstance ( scores , dict ) or isinstance ( bboxes , dict ) : with tf . name_scope ( scope , 'bboxes_sort_dict' ) : d_scores = { } d_bboxes = { } for c in scores . keys ( ) : s , b = bboxes_sort ( scores [ c ] , bboxes [ c ] , top_k = tf . minimum ( tf . shape ( scores [ c ] ) [ 0 ] , top_k ) ) d_scores [ c ] = s d_bboxes [ c ] = b return d_scores , d_bboxes # Tensors inputs. with tf . name_scope ( scope , 'bboxes_sort' , [ scores , bboxes ] ) : # Sort scores... scores , idxes = tf . nn . top_k ( scores , k = top_k , sorted = True ) #return scores, tf.gather(bboxes, idxes) return pad_axis ( scores , 0 , top_k , axis = 0 ) , pad_axis ( tf . gather ( bboxes , idxes ) , 0 , top_k , axis = 0 )