I think you could rephrase your question to “How can you refer back from a specific prediction to its source (e.g. file name)?”
I had a similar question a few months ago (How to review images for bad classifications) and I think I also got to the file name by just adding 1-2 extra lines of code.