Are you preloading the complete dataset and are the 500 slices the complete set or do you have more files (each with 500 slices)?
If you are preloading the data, you could do it in the __init__ method of your Dataset and load each slice as a single sample in __getitem__.
I’m not sure, how ImageDataset1 works, as img_lrr and img_hrr seem to be global variables. What shapes do these arrays have?
PS: you can post code snippets by wrapping them in three backticks ```