Predicting features of an image

We can try predicting the features of an image. This is done by simply preparing the image in a shape and format required by MXNet and Inception V3 and running the mx.predict function. This is shown as follows:

img = imresize(load("sample-images/bird-3183441_640.jpg"), (224, 224));img = permutedims(Float16.(channelview(img)), (3, 2, 1));img[:, :, :] *= 256.0;img[:, :, :] -= 128.;img[:, :, :] /= 128.;img = reshape(img, 224, 224, 3, 1);mx_data = mx.zeros((224, 224, 3, 1));mx_data[1:1] = img;data_provider = mx.ArrayDataProvider(:data => mx_data);### PREDICTING@time pred = mx.predict(nnet, data_provider);

Done! New features are stored in a pred variable. We can use the size function to see the dimensionality and ...

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.