Preparing the datasets

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:

  1. 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));
  1. Next, we normalize the images:
img[:, :, :] *= 256.0;img[:, :, :] -= 128.;img[:, :, :] /= 128.;
  1. Next, we prepare the MXNet ArrayDataProvider consisting of this one image:
img = reshape(img, 224, 224, 3, 1);mx_data = mx.zeros((224, ...

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.