monitor='val_acc', verbose=1, save_best_only=True) early_stop = EarlyStopping(monitor='val_loss', min_delta=0, patience=20, verbose=0, mode='auto') # this is the augmentation configuration we will use for training train_datagen = ImageDataGenerator( samplewise_center=True, # 输入数据集去中心化,按feature执行 rescale=1. / 255, # 重缩放因子 shear_range=0.1, # 剪切强度(逆时针方向的剪切变换角度) zoom_range=0.1, # 随机缩放的幅度 rotation_range=10., # 图片随机转动的角度 width_shift_range=0.1, # 图片水平偏移的幅度 height_shift_range=0.1, # 图片竖直偏移的幅度 horizontal_flip=True, # 进行随机水平翻转 vertical_flip=True, # 进行随机竖直翻转 ) # this is the augmentation configuration we will use for validation: # only rescaling val_datagen = ImageDataGenerator(rescale=1. / 255) train_generator = train_datagen.flow_from_directory( train_data_dir, target_size=(img_width, img_height), batch_size=batch_size, shuffle=True,
# 共21类(影像中所有地物的名称) ObjectNames = ['agricultural', 'airplane', 'baseballdiamond', 'beach', 'buildings', 'chaparral', 'denseresidential', 'forest', 'freeway', 'golfcourse', 'harbor', 'intersection', 'mediumresidential', 'mobilehomepark', 'overpass', 'parkinglot', 'river', 'runway', 'sparseresidential', 'storagetanks', 'tenniscourt' ] root_path = '/media/files/xdm/classification' weights_path = os.path.join(root_path, 'weights/UCMerced_LandUse/InceptionV3_UCM_weights.h5') test_data_dir = os.path.join(root_path, 'data/UCMerced_LandUse/test/') # test data generator for prediction test_datagen = ImageDataGenerator(rescale=1. / 255) test_generator = test_datagen.flow_from_directory( test_data_dir, target_size=(img_width, img_height), batch_size=batch_size, shuffle=False, # Important !!! classes=None, class_mode=None) test_image_list = test_generator.filenames print('Loading model and weights from training process ...') InceptionV3_model = load_model(weights_path) print('Begin to predict for testing data ...')