def replace_black_with_white_color(image_tensor):
is_black = tf.reduce_all(
tf.equal(image_tensor, (0, 0, 0)),
axis=-1
)
is_black = tf.stack([is_black] * 3, axis=-1)
return tf.where(
is_black,
255 * tf.ones_like(image_tensor),
image_tensor
)
评论列表
文章目录