Search code examples
tensorflowkerasconv-neural-networkprediction

CNN predictions


I have built and trained a model with Keras using both a training and validation sets. I would like to make predictions on unlabelled data, I have one folder containing 300 images of dogs, cats and horses. In the predictions I get the probabilities for each class.

How to I get a final output that tells / shows me how many of those 300 images belong to each class?

I upload the model

new_model = tf.keras.models.load_model('model')

I then reformat the testing images

test_batches = train_datagen.flow_from_directory(
    'test_images',
    target_size=(224, 224),
    batch_size=10,
    classes = None,
    class_mode= None)

and then I finally make a prediction

predictions = new_model.predict(test_batches, steps=30, verbose=0)

Solution

  • import collections, numpy
    collections.Counter(np.argmax(predictions, axis = 1))