I’m not really sure, what makes the DataLoader hang, but it’s good to hear it’s working now!
Your custom loader looks more or less like the default pil_loader besides the try block.
However, as Windows doesn’t use fork to create new workers, it might often be problematic, if you don’t use a “main guard”, as the whole module-level code will be executed in all child processes.