In [10]:
# define the expected input shape for the model
# it is important to consider that parameters such this, where input height and width has
# the same can negatively affect image so sometimes it is good to test with different values
input_w, input_h = 416, 416
# select new photo for testing
photo_filename = 'test_image.jpg'
image, image_w, image_h = load_image_pixels(photo_filename, (input_w, input_h))


Use predict function to predict the label, and a list of three NumPy arrays, the shape of which is displayed as output. These arrays predict both the bounding boxes and class labels but are encoded:

This model was trained on the MSCOCO dataset, so it can only predict object from that dataset. For testing, it is good to use pictures with object classes that we know that the model can recognize.

In [11]:
# make prediction
yhat = model.predict(image,steps=2)
# print the shape of the list of arrays
print([a.shape for a in yhat])

[(2, 13, 13, 255), (2, 26, 26, 255), (2, 52, 52, 255)]