How to use a variable to represent input’s data in a forward_hook?

Thank you for your reply.I solved the above problem! I also have a question that I wish you can help me.
I have seen this Questions about ImageFolder about imagefolder. But I’m not really understand.
I have a picture datasets. Divided into trian and val two files Folder. Each folder has 0 and 1 subfolders.

I also create lables.txt about train and val. How do I load this dataset into pytorch?