I’m using a pretty simple set of steps designed to prepare images for feature extraction from a pre trained resnet 152 model.
img=Image.open("Documents/img.png")
# Load the pretrained model
model = models.resnet152(pretrained=True)
# Use the model object to select the desired layer
layer = model._modules.get('fc')
# Set model to evaluation mode
model.eval()
transformations = torchvision.transforms.Compose([
torchvision.transforms.Resize(256),
torchvision.transforms.CenterCrop(224),
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
t_img = transformations(img)
What I'm trying to understand is what it means to normalize the images with those means and standard deviations? We obviously aren't setting pixel values right? My understanding is that pixel values should be integers between 0 and 255, so what does it mean to normalize in this context?