It looks like you are trying to get the first batch from the initialization of your DataLoader.
Could you try to first instantiate your DataLoader, then get the batches in a for loop:
train_loader = TrainLoader(im_dir=...)
for t_images, t_label in train_loader:
print(t_images.shape)
The answer from @ptrblck should solve the problem. But to add more, the problem is in the following line:
Here TrainLoader is a class, and you want to create an instance (object) from this class. I would change the name to TrainSet t avoid confusion with a loader. So, on the left-hand side there should be only one variable as an object created from the class TrainSet (not a tuple):
Then, once you have created an instance of TrainSet, then should be able to use that in a for-loop to get samples.
Note that while the above works in an infinite loop that gives samples of size 1, you may also need to use torch.utils.data.DataLoader, to get batches of data instead of one sample at a time: