def _resize_aux(image, new_shorter_edge_tensor):
shape = tf.shape(image)
height = shape[0]
width = shape[1]
height_smaller_than_width = tf.less_equal(height, width)
new_height_and_width = cf.cond(
height_smaller_than_width,
lambda: (new_shorter_edge_tensor, _compute_longer_edge(height, width, new_shorter_edge_tensor)),
lambda: (_compute_longer_edge(width, height, new_shorter_edge_tensor), new_shorter_edge_tensor)
)
# workaround since tf.image.resize_images() does not work
image = tf.expand_dims(image, 0)
image = tf.image.resize_bilinear(image, tf.pack(new_height_and_width))
return tf.squeeze(image, [0])
评论列表
文章目录