getInputImageArray = (imgFile, normalize=true) => {
  let canvas = document.createElement('canvas');
  canvas.style.cssText = 'display:none;';
  document.getElementsByTagName('body')[0].appendChild(canvas);
  let context = canvas.getContext('2d');

  return new Promise((resolve, reject) => {
    let inputImage = new Image();
    inputImage.crossOrigin = "Anonymous";
    inputImage.src = imgFile;
    let canvasImage;
    inputImage.onload = () => {
      canvas.width = inputImage.width;
      canvas.height = inputImage.height;
      // Resize the input image of the network if it is too large to simply crop
      // the center 64x64 portion in order to still provide a representative
      // input image into the network.
      if (inputImage.width > networkInputSize || inputImage.height > networkInputSize) {
        // Step 1 - Resize using smaller dimension to scale the image down. 
        let resizeCanvas = document.createElement('canvas'),
            resizeContext = resizeCanvas.getContext('2d');
        let smallerDimension = Math.min(inputImage.width, inputImage.height);
        const resizeFactor = (networkInputSize + 1) / smallerDimension;
        resizeCanvas.width = inputImage.width * resizeFactor;
        resizeCanvas.height = inputImage.height * resizeFactor;
        resizeContext.drawImage(inputImage, 0, 0, resizeCanvas.width,
          resizeCanvas.height);

        // Step 2 - Flip non-square images horizontally and rotate them 90deg since
        // non-square images are not stored upright.
        if (inputImage.width != inputImage.height) {
          context.translate(resizeCanvas.width, 0);
          context.scale(-1, 1);
          context.translate(resizeCanvas.width / 2, resizeCanvas.height / 2);
          context.rotate(90 * Math.PI / 180);
        }

        // Step 3 - Draw resized image on original canvas.
        if (inputImage.width != inputImage.height) {
          context.drawImage(resizeCanvas, -resizeCanvas.width / 2, -resizeCanvas.height / 2);
        } else {
          context.drawImage(resizeCanvas, 0, 0);
        }
        canvasImage = context.getImageData(0, 0, resizeCanvas.width,
          resizeCanvas.height);

      } else {
        context.drawImage(inputImage, 0, 0);
        canvasImage = context.getImageData(0, 0, inputImage.width,
          inputImage.height);
      }
      // Get image data and convert it to a 3D array
      let imageData = canvasImage.data;
      let imageWidth = canvasImage.width;
      let imageHeight = canvasImage.height;

      // Remove this newly created canvas element
      canvas.parentNode.removeChild(canvas);

      resolve(imageDataTo3DTensor(imageData, imageWidth, imageHeight, normalize));
    }
    inputImage.onerror = reject;
  })
}
Get the 3D pixel value array of the given image file.

@param {string} imgFile File path to the image file
@returns A promise with the corresponding 3D array