# Return the learning rate
    return alpha

# Show information on the process ID
print("[INFO]: Process ID: {}".format(os.getpid()))

# Grab the list of images
print("[INFO]: Loading images....")
image_paths = list(paths.list_images(args["dataset"]))

#print(image_paths)

# Initialize the image preprocessors
img_size = args["image_size"]
sp = SimplePreprocessor(img_size, img_size)
itap = ImageToArrayPreprocessor()

# Load the dataset and scale the raw pixel intensities to the range [0, 1]
sdl = SimpleDatasetLoader(preprocessors=[sp, itap])
(data, labels) = sdl.load(image_paths, verbose=500)
data = data.astype("float") / 255.0

# Split the data into training data (75%) and testing data (25%)
(trainX, testX, trainY, testY) = train_test_split(data, labels, test_size=0.25, random_state=42)

# Convert the labels from integers to vectors
lb = LabelBinarizer()
trainY = lb.fit_transform(trainY)
testY = lb.fit_transform(testY)

# construct the image generator for data augmentation
Beispiel #2
0
"""

#importing the necessasry libnrariea
from config import dogs_vs_cats_config as config
from utilities.preprocessing import CropPreprocessor
from utilities.preprocessing import MeanPreprocessor, ImageToArrayPreprocessor
from utilities.io import HDF5DatasetGenerator
from sklearn.metrics import classification_report
from keras.models import load_model
import json
import numpy as np

#brings in from the meanPreprocessor
means = json.loads(open(config.DATASET_MEAN).read())
mp = MeanPreprocessor(means['R'], means['G'], means['B'])
iap = ImageToArrayPreprocessor(227, 227)
cp = CropPreprocessor(227, 227)
model = load_model(config.MODEL_PATH)

#making a generator obhject
testGen = HDF5DatasetGenerator(config.TEST_HDF5,
                               32,
                               preprocessors=[mp],
                               classes=2)
predictions = []
for (images, labels) in testGen.generator(passes=1):
    for image in images:
        crops = cp.preprocess(image)
        crops = np.array([iap.preprocess(c) for c in crops], dtype="float32")
        pred = model.predict(crops)
        predictions.append(pred.mean(axis=0))