Hi Patrick,
Saved the images as png to try fitting a 2d CNN, really struggling to load a png properly. I think im not that far. I’ve followed the PyTorch tutorial then had a PIL error, got some help and fix that, now another error:
PicklingError: Can’t pickle <class ‘main.MyDataset’>: it’s not the same object as main.MyDataset
My pipeline so far is below:
class MyDataset(Dataset):
"""Face Landmarks dataset."""

def __init__(self, csv_file, root_dir, transform=None):

    self.image_frame = pd.read_csv(csv_file)
    self.root_dir = root_dir
    self.transform = transform

def __len__(self):
    return len(self.image_frame)

def __getitem__(self, idx):
    if torch.is_tensor(idx):
        idx = idx.tolist()

    img_name = os.path.join(self.root_dir,
                            self.image_frame.iloc[idx, 0])
    
    image = Image.open(img_name)
    sample = {'image': image}

    if self.transform:
        sample = self.transform(sample)

    return sample
 
## Data transforms


data_transforms = transforms.Compose([
    transforms.Grayscale(num_output_channels=1),
    transforms.Resize(256),
    transforms.CenterCrop(256),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406],
                     std=[0.229, 0.224, 0.225] )])

Open and transform the data

transformed_dataset = MyDataset(csv_file='metadata.csv',
                                       root_dir="C:/Users/JOBS/Desktop/comp 8420 NN/Assignment_2/figures/",
                                       transform = transformed_dataset)    

Load data

dataloader = DataLoader(transformed_dataset, batch_size=4,
                    shuffle=True, num_workers=4)