有没有另一种方法可以指定另一个文件夹中我的数据集的路径

时间:2021-02-19 11:28:48

标签: python file path

这是不断产生错误的代码,也是我用来指定数据集路径的代码

            imgs = os.listdir(source_path+'/'+ t[folder + (batch*batch_size)].split(';')[0])

在我运行下面的代码之后

   test_generator=ModelConv3D1()
test_generator.initialize_path(project_folder)
test_generator.initialize_image_properties(image_height=160,image_width=160)
test_generator.initialize_hyperparams(frames_to_sample=30,batch_size=3,num_epochs=1)

g=test_generator.generator(test_generator.val_path,test_generator.val_doc,augment=True)
batch_data, batch_labels=next(g)
fig, axes = plt.subplots(nrows=1, ncols=2)
axes[0].imshow(batch_data[0,15,:,:,:])   
axes[1].imshow(batch_data[3,15,:,:,:])

它正在生成此错误

            ---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-70-78f3070a63f7> in <module>
          5 
      6 g=test_generator.generator(test_generator.val_path,test_generator.val_doc,augment=True)
----> 7 batch_data, batch_labels=next(g)
      8 fig, axes = plt.subplots(nrows=1, ncols=2)
      9 axes[0].imshow(batch_data[0,15,:,:,:])

<ipython-input-62-b58355e519b5> in generator(self, source_path, folder_list, augment)
     30 
     31             for batch in range(num_batches):
---> 32                 batch_data, batch_labels= self.one_batch_data(source_path,t,batch,batch_size,img_idx,augment)
     33                 yield batch_data, batch_labels
     34 

<ipython-input-62-b58355e519b5> in one_batch_data(self, source_path, t, batch, batch_size, img_idx, augment, remaining_seq)
     52         for folder in range(seq_len):
     53             # read all the images in the folder
---> 54             imgs = os.listdir(source_path+'/'+ t[folder + (batch*batch_size)].split(';')[0])
     55             for idx,item in enumerate(img_idx):
     56                 image = imread(source_path+'/'+ t[folder + (batch*batch_size)].strip().split(';')[0]+'/'+imgs[item]).astype(np.float32)

FileNotFoundError: [WinError 3] The system cannot find the path specified: '\\Project_data/val/WIN_20180907_15_38_42_Pro_Thumbs Up_new'

0 个答案:

没有答案