Solved by Janine in post #2 
              
              
                I have somehow managed to achieve my goal using the following code: 
data_dir = './data'  # the folder has multiple subfolders which contain the pt files
imgs_pt = []
labels_pt = []

i = 0
for root, dirs, files in os.walk(data_dir):
    for file in files:
        path = os.path.join(root, file)
    …