解决方法: from tensorflow.keras.preprocessing.image import img_to_array, load_img img = load_img(img_path, target_size=(48, 48), color_mode=“grayscale”) img = img_to_array(img) # 灰度化