AttributeError: 'tuple' object has no attribute 'assert_is_compatible_with'
时间: 2023-11-08 14:04:23 浏览: 158
【Python】AttributeError: ‘AutoSchema’ object has no attribute ‘get_link’
5星 · 资源好评率100%
对不起,我犯了一个错误。PaddlePaddle没有 `assert_is_compatible_with` 这个方法。你可以使用 `shape` 属性来检查张量的形状。请尝试以下代码:
import paddle.vision.transforms as T
import inverse_isp
import os
import glob
from PIL import Image
import numpy as np
def read_jpg(filename):
"""Read an 8-bit JPG file from disk and normalizes to [0, 1]."""
image_file = open(filename, 'rb').read()
image = Image.open(io.BytesIO(image_file))
return T.ToTensor()(image)
def read_img(filename):
"""Read an image in most formats."""
image_file = open(filename, 'rb').read()
image = Image.open(io.BytesIO(image_file))
return T.ToTensor()(image)
def convert_to_raw(image):
"""Unprocess sRGB to packed raw."""
assert len(image.shape) == 3 and image.shape[-1] == 3, "Invalid image shape"
image, metadata = inverse_isp.unprocess(image)
return image, metadata
阅读全文