这是我现有的代码,由于没有返回4D输入而给我一个错误。这是代码,我有什么办法可以更改它?
img = cv2.cvtColor(cv2.imread(os.path.join(root, f_name)), cv2.COLOR_BGR2GRAY)
# convert each image of shape (32, 128, 1)
w, h = img.shape
if h > 128 or w > 32:
continue
if w < 32:
add_zeros = np.ones((32-w, h))*255
img = np.concatenate((img, add_zeros))
if h < 128:
add_zeros = np.ones((32, 128-h))*255
img = np.concatenate((img, add_zeros), axis=1)
img = np.expand_dims(img , axis = 2)
# Normalize each image
img = img/255.