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