【发布时间】:2023-03-26 10:04:01
【问题描述】:
我正在尝试重用以下代码段。特定的代码行gt_bg = gt_bg.reshape(*gt_bg.shape, 1) 给了我诸如
gt_bg = gt_bg.reshape(*gt_bg.shape, 1)
SyntaxError: only named arguments may follow *expression
我正在使用Python 2.7,是这个问题吗?如果是这样,如何修改它以使其适合Python2.7?谢谢。
for image_file in image_paths[batch_i:batch_i+batch_size]:
gt_image_file = label_paths[os.path.basename(image_file)]
image = scipy.misc.imresize(scipy.misc.imread(image_file), image_shape)
gt_image = scipy.misc.imresize(scipy.misc.imread(gt_image_file), image_shape)
gt_bg = np.all(gt_image == background_color, axis=2)
gt_bg = gt_bg.reshape(*gt_bg.shape, 1)
gt_image = np.concatenate((gt_bg, np.invert(gt_bg)), axis=2)
images.append(image)
gt_images.append(gt_image)
【问题讨论】:
标签: python-2.7 python-3.x numpy scipy