The error states that the DataLoader receives a PIL image. This is because there are no transforms made (transform=None) on the image. The __getitem__ method of MyDataset passes an unprocessed PIL image to the DataLoader, whereas it should receive a tensor.
You can add a transform that creates a tensor from the PIL image by adding transform:
from torchvision import transforms

transform = transforms.Compose([
    # you can add other transformations in this list
    transforms.ToTensor()
])

as an argument to MyDataset.