我正在尝试准备图像数据以进行图像分割,但遇到错误。我阅读了PIL Image文档,我认为已将所有需要的参数发送给该函数。我在行的开头加了*,这是我得到的错误。
from PIL.Image import Image
im = Image()
image_ids = next(os.walk(DATA_PATH))[1]
X = np.zeros((len(image_ids), IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS), dtype=np.uint8)
Y = np.zeros((len(image_ids), IMG_HEIGHT, IMG_WIDTH, 1), dtype=np.bool)
for n, id_ in tqdm(enumerate(image_ids), total=len(image_ids)):
path = DATA_PATH
img = imread(path + '/' + id_ + '/images/' + 'page' + id_ + '.png')[:,:IMG_CHANNELS]
* img = im.resize(img, size = (IMG_HEIGHT, IMG_WIDTH))
X[n] = img
mask = np.zeros((IMG_HEIGHT, IMG_WIDTH, 1), dtype=np.bool)
for mask_file in next(os.walk(path + '/masks/'))[2]:
mask_ = imread(path + '/masks/' + mask_file)
mask_ = np.expand_dims(im.resize(mask_, (IMG_HEIGHT, IMG_WIDTH), mode='constant',
preserve_range=True), axis=-1)
mask = np.maximum(mask, mask_)
Y[n] = mask
x_train=X
y_train=Y
我似乎找不到任何解决方案。 感谢您的帮助。