def loader(file):
        """Resize and crop image to required dims and return as FP32 array."""

        image = cv2.imread(file)
        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
        w, h = (224, 224)
        image = resize_with_aspectratio(image, h, w)
        image = center_crop(image, h, w)
        image = np.asarray(image, dtype='float32')
        # Transpose.
        image = image.transpose([2, 0, 1])
        return image
 def loader(file):
     image = cv2.imread(file)
     image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
     w, h = (224, 224)
     image = resize_with_aspectratio(image, h, w)
     image = center_crop(image, h, w)
     image = np.asarray(image, dtype='float32')
     # Normalize image.
     means = np.array([123.68, 116.78, 103.94], dtype=np.float32)
     image -= means
     # Transpose.
     image = image.transpose([2, 0, 1])
     return image
    def loader(file):
        img = Image.open(file)
        img = img.convert('RGB')
        img = resize_with_aspectratio(img, 256)
        img = center_crop(img, (224, 224))

        img = np.asarray(img, dtype='float32')
        img /= 255.0
        mean = np.array([0.485,0.456,0.406], dtype=np.float32)
        std = np.array([0.229,0.224,0.225], dtype=np.float32)
        img = (img - mean) / std
        img = img.transpose([2, 0, 1])
        #img = np.asarray(img.reshape((3,224,224)), dtype='float32')
        return img