Based on the error message you are trying to return PIL.Images instead of tensors (or numpy arrays) and the DataLoader will thus raise the error.
Have a look at the data loading tutorial 2, which shows how to transform the images to tensors.
PS: you can post code snippets by wrapping them into three backticks ```.