import os from tensorflow.keras.preprocessing.image import ImageDataGenerator # 设置数据目录 data_dir = 'D:/hand/archive' train_dir = os.path.join(data_dir, 'leapGestRecog') validation_dir = os.path.join(data_dir, 'validation') # 简单的标准化处理 datagen = ImageDataGenerator(rescale=1./255) train_generator = datagen.flow_from_directory(train_dir, target_size=(150, 150), batch_size=32, class_mode='categorical') validation_generator = datagen.flow_from_directory(validation_dir, target_size=(150, 150), batch_size=32, class_mode='categorical')