【问题标题】:AttributeError: 'Tensor' object has no attribute 'read'AttributeError:“张量”对象没有“读取”属性
【发布时间】:2020-06-26 02:06:52
【问题描述】:

我要在一个函数中构建一个双三次图像,然后我想在我的 API 模型的一个层中使用它,我看到这个错误,我该如何解决?谢谢你!!

def model_bicubic(image):
    image = Image.open(image, mode = 'r')
    width, height = image.size
    image_bicubic = image.resize((width*2, height*2), Image.BICUBIC)

    return image_bicubic

【问题讨论】:

    标签: python jupyter spyder


    【解决方案1】:

    您可以通过以下方式尝试:

    def load_image(img_path):
        img = tf.io.read_file(img_path)
        img = tf.io.decode_jpeg(img, channels = 3)
        img = tf.image.resize(img, size = (width, height), method = 'bicubic')
        img = img / 255.0
        return img
    

    为我工作。

    【讨论】:

      猜你喜欢
      • 2020-10-22
      • 2019-02-20
      • 2017-12-06
      • 2018-07-02
      • 2018-06-20
      相关资源
      最近更新 更多