(img_tensor, gtboxes_and_label, target_shortside_len, length_limitation=1200)
return img_tensor, tf.transpose(tf.stack([new_xmin, new_ymin, new_xmax, new_ymax, label], axis=0))
:param img_tensor:[h, w, c], gtboxes_and_label:[-1, 5].  gtboxes: [xmin, ymin, xmax, ymax]
    :param target_shortside_len:
    :param length_limitation: set max length to avoid OUT OF MEMORY
    :return:
def short_side_resize(img_tensor, gtboxes_and_label, target_shortside_len, length_limitation=1200):
    '''

    :param img_tensor:[h, w, c], gtboxes_and_label:[-1, 5].  gtboxes: [xmin, ymin, xmax, ymax]
    :param target_shortside_len:
    :param length_limitation: set max length to avoid OUT OF MEMORY
    :return:
    '''
    img_h, img_w = tf.shape(img_tensor)[0], tf.shape(img_tensor)[1]
    new_h, new_w = tf.cond(tf.less(img_h, img_w),
                           true_fn=lambda: (target_shortside_len,
                                            max_length_limitation(target_shortside_len * img_w // img_h, length_limitation)),
                           false_fn=lambda: (max_length_limitation(target_shortside_len * img_h // img_w, length_limitation),
                                             target_shortside_len))

    img_tensor = tf.expand_dims(img_tensor, axis=0)
    img_tensor = tf.image.resize_bilinear(img_tensor, [new_h, new_w])

    xmin, ymin, xmax, ymax, label = tf.unstack(gtboxes_and_label, axis=1)

    new_xmin, new_ymin = xmin * new_w // img_w, ymin * new_h // img_h
    new_xmax, new_ymax = xmax * new_w // img_w, ymax * new_h // img_h
    img_tensor = tf.squeeze(img_tensor, axis=0)  # ensure image tensor rank is 3

    return img_tensor, tf.transpose(tf.stack([new_xmin, new_ymin, new_xmax, new_ymax, label], axis=0))
def short_side_resize ( img_tensor , gtboxes_and_label , target_shortside_len , length_limitation = 1200 ) : img_h , img_w = tf . shape ( img_tensor ) [ 0 ] , tf . shape ( img_tensor ) [ 1 ] new_h , new_w = tf . cond ( tf . less ( img_h , img_w ) , true_fn = lambda : ( target_shortside_len , max_length_limitation ( target_shortside_len * img_w // img_h , length_limitation ) ) , false_fn = lambda : ( max_length_limitation ( target_shortside_len * img_h // img_w , length_limitation ) , target_shortside_len ) ) img_tensor = tf . expand_dims ( img_tensor , axis = 0 ) img_tensor = tf . image . resize_bilinear ( img_tensor , [ new_h , new_w ] ) xmin , ymin , xmax , ymax , label = tf . unstack ( gtboxes_and_label , axis = 1 ) new_xmin , new_ymin = xmin * new_w // img_w , ymin * new_h // img_h new_xmax , new_ymax = xmax * new_w // img_w , ymax * new_h // img_h img_tensor = tf . squeeze ( img_tensor , axis = 0 ) # ensure image tensor rank is 3 return img_tensor , tf . transpose ( tf . stack ( [ new_xmin , new_ymin , new_xmax , new_ymax , label ] , axis = 0 ) )