Predicting new images

Using the newly trained models on new images requires us to repeat the data preparation step and pass them to the mx.predict function. We will try to predict classes for the first 1:10 images from the test dataset. This is done with the following code:

data_array = mx.zeros((size(test_x, 1, 2)..., 10));mx.copy!(data_array, test_x[:, :, 1:10]);data_provider = mx.ArrayDataProvider(:data => data_array);results = round(mx.predict(nnet, data_provider; verbosity = 0), 2)println(results)

The results variable is a 10x10 matrix where each row represents an image and columns represent the probability for each of the 10 classes. This is depicted with the following output:

Main> round.(mx.predict(nnet, data_provider; verbosity = ...

Get Hands-On Computer Vision with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.