So I am trying to build a data augmenter from the ImageFolder loader.
But what I have is giving me the ‘Image’ object has no attribute ‘shape’ error. I think I have everything correct but not sure about it.
This is my code on Kaggle for it
https://www.kaggle.com/matthewmillar/kernel2879505a11/edit
But here is my transforms that I would like to use
mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]
size = (224,224)
train_transform = transforms.Compose([
transforms.Resize(224),
transforms.RandomHorizontalFlip(),
transforms.RandomErasing(p=0.4, scale=(0.09, 0.25), ratio=(0.3, 3.3), value=0, inplace=False),
transforms.RandomRotation(45),
transforms.ToTensor(),
transforms.Normalize(mean, std)
])
val_transform = transforms.Compose([
transforms.Resize(size),
transforms.ToTensor(),
transforms.Normalize(mean, std)
])
And this is my dataset and loaders
# Make image loaders
# Hyperparmas
batch_size = 32
num_workers = 0
train_dataset = torchvision.datasets.ImageFolder(TRAIN_SET, transform=train_transform)
test_dataset = torchvision.datasets.ImageFolder(TEST_SET, transform=val_transform)
train_loader = torch.utils.data.DataLoader(train_dataset,
batch_size=batch_size,
shuffle=True,
num_workers=num_workers)
test_loader = torch.utils.data.DataLoader(test_dataset,
batch_size=batch_size,
shuffle=True,
num_workers=num_workers)
And this is how I am calling it
dataiter = iter(train_loader)
images, labels = dataiter.next()
I think everything is right but not 100% sure.
Thank you for any help with this