1
我正在尝试重新使用下面的代码段。代码gt_bg = gt_bg.reshape(*gt_bg.shape, 1)
特定行给我的错误信息,如可能与python 2.7相关的一个代码段错误与python 3.x
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)
感谢您的回复。声称原始代码段可以正常运行python3.x。我在Python 2.7下运行它给了我错误的信息。这就是为什么我怀疑它是python版本问题。而且,gt_bg.shape +(1,)是什么意思?谢谢 – user297850