Running the predictions

Running a prediction is as simple as calling the mx.predict function. The additional work involved is in merging the predictions with synset. Consider the following code:

@time pred = mx.predict(mx_model, mx.ArrayDataProvider(:data => mx_data));# Main> INFO: TempSpace: Total 11 MB allocated on CPU0# Main>  0.198417 seconds (29.07 k allocations: 2.213 MiB)

I have also included the @time macro so that we have an approximate time for how long it takes to run the prediction. You can see that it is twice as fast as Inception V3. Let's verify whether the prediction is correct:

mxval, mxindx = findmax(pred[:, 1]);println(mxval, " ", mxindx, " ", synset[mxindx])

We get the following output at 0.68557036 131 'n02007558 flamingo' ...

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.