使用 tf.image.decode_image 时出错“b'无法将字节解码为

    image_path = tf.keras.utils.get_file('img.jpeg', 'link') #'link' in my code is replaces with a alink to a google drive image

    image_raw = tf.io.read_file(image_path)

    image = tf.image.decode_image(image_raw)

该代码是我在网上找到的用于生成对抗性示例的代码的一部分。在原始代码中,他们传递了一个在线图像的链接tf.keras.utils.get_file,并且运行它不会出现错误。但是,当我将其替换为指向我的谷歌驱动器上的图像的链接时,我收到此错误InvalidArgumentError: Expected"tf.Tensor(False, shape=(), dtype=bool)' to be true. Summarized data: b'Unable to decode bytes as JPEG, PNG, GIF, or BMP'" referring to tf.image.decode_image


蛊毒传说
浏览 1329回答 1
1回答

www说

听起来您没有使用直接下载链接,因此您的文件没有被下载。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python