簡體   English   中英

AttributeError: 'Tensor' 對象沒有屬性 'read'

[英]AttributeError: 'Tensor' object has no attribute 'read'

我將在一個函數中構建一個雙三次圖像,然后我想在 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

您可以通過以下方式嘗試此操作:

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

為我工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM