“IsADirectoryError: [Errno 21] Is a directory: ” It is a file

后端 未结 3 1454
抹茶落季
抹茶落季 2020-12-19 02:10

I already split the data into test and training set into the different folder. Now I need to load the patient data. Each patient has 8 images.

def load_datas         


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 02:55

    It seems that ./data/preprocessed_data/train/Patient009969 is a directory, not a file.

    os.listdir() returns both files and directories.

    Maybe try using os.walk() instead. It treats files and directories separately, and can recurse inside the subdirectories to find more files in a iterative way:

    data_paths = [os.path.join(pth, f) 
        for pth, dirs, files in os.walk(in_dir) for f in files]
    

提交回复
热议问题