How to interpret keras " predict_generator " output?

Viewed 7883

I am implementing image classification project .I have generated model and saved it . It was successfully trained . When i use predict_generator in keras to classify the test images then for each image i am getting multiple rows for each image in prediction numpy array.

Prediction Code :

from keras.models import load_model
from keras.preprocessing.image import ImageDataGenerator
from keras.preprocessing.image import img_to_array, load_img
import numpy as np

# dimensions of our images.
img_width, img_height = 150, 150
batch_size = 16

test_model = load_model('first_try1.h5')


img = load_img('data/train/dogs/dog.2.jpg',False,target_size=(img_width,img_height))

validation_data_dir="test1"

test_datagen = ImageDataGenerator(rescale=1. / 255)
validation_generator = test_datagen.flow_from_directory(
    validation_data_dir,
    target_size=(img_width, img_height),
    batch_size=batch_size,
    class_mode='binary')
print(len(validation_generator.filenames))
predictions=test_model.predict_generator(validation_generator,len(validation_generator.filenames));
#print(predictions)

Output :

Found 5 images belonging to 1 classes.
5
[[ 0.0626688 ]
 [ 0.07796276]
 [ 0.46529126]
 [ 0.28495458]
 [ 0.07343803]
 [ 0.07343803]
 [ 0.0626688 ]
 [ 0.46529126]
 [ 0.28495458]
 [ 0.07796276]
 [ 0.0626688 ]
 [ 0.28495458]
 [ 0.07796276]
 [ 0.46529126]
 [ 0.07343803]
 [ 0.07796276]
 [ 0.46529126]
 [ 0.0626688 ]
 [ 0.07343803]
 [ 0.28495458]
 [ 0.0626688 ]
 [ 0.07796276]
 [ 0.46529126]
 [ 0.07343803]
 [ 0.28495458]]
1 Answers
Related