def transform_image(image): image = torchvisionTransforms.resize(image, 256) image = torchvisionTransforms.center_crop(image, 224) image = torchvisionTransforms.to_tensor(image) image = torchvisionTransforms.normalize(image, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) return image
def transform_image(image): """ Given a PIL image, transform it to a normalized tensor for classification. """ image = torchvisionTransforms.resize(image, 256) image = torchvisionTransforms.center_crop(image, 224) image = torchvisionTransforms.to_tensor(image) image = torchvisionTransforms.normalize(image, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) return image