rajora/binary-classification-galaxies
0
1from PIL import Image2import torchvision.transforms as transforms3 4IMAGE_SHAPE = (200, 200)5 6def transform_image(image_path):7 """8 Loads, transforms, and prepares the image for the model.9 10 Args:11 image_path (str): Path to the image.12 13 Returns:14 torch.Tensor: Transformed image ready for the model.15 """16 17 transform = transforms.Compose([18 transforms.Resize(IMAGE_SHAPE),19 transforms.RandomHorizontalFlip(),20 transforms.RandomRotation(degrees=10),21 transforms.ToTensor(),22 ])23 24 image = Image.open(image_path).convert('RGB')25 image = transform(image)26 image = image.unsqueeze(0) # Add batch dimension27 return image