我试图让 tf.image.sobel_edges 在 tensorflow 2.2.0 中工作,但似乎即使是最简单的例子也不起作用:
img_path = "./test.jpg"
image = tf.io.read_file(img_path)
image = tf.image.decode_image(image, channels=3)
img = tf.image.convert_image_dtype(image, tf.float32)
sobel = tf.image.sobel_edges(img)
导致tensorflow.python.framework.errors_impl.InvalidArgumentError: 第一个维度的 paddings must be the rank of inputs[4,2], [224,224,3] [Op:MirrorPad]
我在想这可能与通道排序有关,并且该函数正在寻找一个 alpha 通道,但我不知道 2 是什么。有人在 tf-2 中使用过这个吗?