我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用keras.preprocessing()。
def test_images_generator(test_path): ''' Creates a generator that pulls images from a test directory that contains shade vs sunny subdirectories. ''' from keras.utils.np_utils import to_categorical from keras.preprocessing import image from keras.preprocessing.image import ImageDataGenerator from keras.applications.resnet50 import preprocess_input from sklearn.model_selection import train_test_split from image_utilities import load_images_from_directory, preprocess_input_resnet import numpy as np #load_images from from the train and val directories test_datagen = ImageDataGenerator(preprocessing_function=preprocess_input_resnet) test_generator = test_datagen.flow_from_directory(directory=test_path, target_size=[224, 224], batch_size=26, class_mode='categorical') return test_datagen, test_generator