为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

蛊毒传说 2023-08-22 16:33:32
    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
查看完整描述

1 回答

?
www说

TA贡献1775条经验 获得超8个赞

听起来您没有使用直接下载链接,因此您的文件没有被下载。

查看完整回答
反对 回复 2023-08-22
  • 1 回答
  • 0 关注
  • 1323 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信