def preprocess_img(img):
    """Pre-process image."""
    # normalize
    img = img / 128.0  # between 0 and 2
    img -= 1.0  # between -1 and 1
    # transpose
    img = img.transpose((2, 0, 1))
    return img