I assume you are referring to the image name (or path), not the class name.
If so, you could create a custom Dataset as described here 3 and return the image name in the __getitem__ additionally to the data and target tensors. Inside the DataLoader loop you would then have 3 values and could print the image name as well:
for i, (inputs, labels, name) in enumerate(dataloaders['val']):
    ...