def mirror(image, boxes):
def doMirror(image, boxes):
image = tf.reverse(image, axis=[2])
x0,y0,x1,y1 = tf.unstack(boxes, axis=1)
w=tf.cast(tf.shape(image)[2], tf.float32)
x0_m=w-x1
x1_m=w-x0
return image, tf.stack([x0_m,y0,x1_m,y1], axis=1)
uniform_random = tf.random_uniform([], 0, 1.0)
return tf.cond(uniform_random < 0.5, lambda: tf.tuple([image, boxes]), lambda: doMirror(image, boxes))
评论列表
文章目录