#NoPayJan Offer - Access all CloudxLab Courses for free between 1st to 31st JanEnroll Now >>
Now that we have loaded the image and the pre-trained network, we shall preprocess the image, feed it to the neural network to predict the class of the image.
image.img_to_array : Converts a PIL Image instance to a Numpy array.
tensorflow.keras.applications.resnet50.preprocess_input : The images are converted from RGB to BGR, then each color channel is zero-centered with respect to the ImageNet dataset, without scaling.
tensorflow.keras.applications.resnet50.decode_predictions : Decodes the prediction into a list of tuples (class, description, probability)
Converts the PIL image
x = << your code comes here >>(img)
The model expects to be fed with an array of images. So write as follows:
x = << your code comes here >>(x)
Predict the class probabilities of the input image
preds = << your code comes here>>(x)
Decode the predictions and print the top 3 prediction probabilities as follow:
print('Predicted:', decode_predictions(preds, top=3))
We could see that the image has been correctly predicted as a lion with as high as 0.9998623 probability. This is a spectacular work!
No hints are availble for this assesment
Answer is not availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here