Preparing datasets for running MobileNet is identical to Inception V3. The only parameter that should be adjusted is the size of the images. MobileNet V2 requires images to be 224 x 244 pixels large. Let's see how we can do this:
- Let's start by loading the image and converting it to a float and ordering the dimensions as required by MXNet and MobileNet V2:
img = imresize(load("sample-images/bird-3183441_640.jpg"), (224, 224));
img = permutedims(Float16.(channelview(img)), (3, 2, 1));
- Next, we normalize the images:
img[:, :, :] *= 256.0;
img[:, :, :] -= 128.;
img[:, :, :] /= 128.;
- Next, we prepare the MXNet ArrayDataProvider consisting of this one image:
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)
The dataset is ready to run the predictions!