Are you sure the dict throws this error?
It seems to work on my machine.
I guess the DataLoader's default_collate method throws an error like

TypeError: batch must contain tensors, numbers, dicts or lists

If you really want to return PIL.Images, you could write your own collate_fn.
Usually you would apply the transformation in __getitem__ and store the processed sample.
Wouldn’t that work