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 => mx_data)
The dataset is ready to run the predictions!