You could create a custom Dataset and return the image name with the data and target samples.
This would make sure that, even after shuffling, you would still get the corresponding file names for the current data and target batch.
This tutorial 360 gives you a good overview on writing a custom Dataset.