Preparing the datasets

Every model you use will have some specific requirements for image shape. To use the Inception V3 model, we are required to have ArrayDataProvider consisting of normalized three channel images such as (229, 299, 3). Also, as usual, it should be packed to mx.NDArray. Consider the following code:

img = imresize(load("sample-images/bird-3183441_640.jpg"), (299, 299));img = permutedims(Float16.(channelview(img)), (3, 2, 1));

Next, we will normalize the images:

img[:, :, :] *= 256.0;img[:, :, :] -= 128.;img[:, :, :] /= 128.;

Next, we prepare the MXNet ArrayDataProvider consisting of this one image:

img = reshape(img, 299, 299, 3, 1);mx_data = mx.zeros((299, 299, 3, 1));mx_data[1:1] = img;data_provider = mx.ArrayDataProvider(:data ...

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.