Try doing it iteratively with tf.data.Dataset
. The pictures will only be resized while iterating through the dataset, one batch at a time. So it won't create a new dataset in memory.
new_img = np.array(new_img)
ds = tf.data.Dataset.from_tensor_slices(new_img).
map(lambda x: tf.resize(x/255, (297, 297)))
print(next(iter(ds)))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…