我正在尝试通过Google colab读取Google驱动器中的文件,并将其重定向到我的项目。
import os
os.chdir("/content/drive/My Drive/Thesis/")
!ls
看来这条路是对的。
2D loss_test.py Run.ipynb 'train from scratch'
Base_Model.py model.py 'saved models' 'try out codes.py'
checkpoints Plot.py Siamese_Gan.py 'try read text.py'
'fine tune' __pycache__ Siamese_Network.py
Fine_Tuning.py 'raw evalaute' 'split data'
loss.py read_Images.py test.py
但是如果我运行代码以读取文件(在我自己的计算机上可以正常工作),它仍然找不到目录。
!python read_Images.py #program to read files
2020-06-13 12:56:45.621514: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
Traceback (most recent call last):
File "read_Images.py", line 124, in <module>
train_imgs, train_l, val_imgs, val_l = create_data.split_data(3000, 200)
File "read_Images.py", line 80, in split_data
all_images, all_labels = self.images_patches()
File "read_Images.py", line 55, in images_patches
data, labels = self.read_images(self.name)
File "read_Images.py", line 39, in read_images
with open(txt_path, 'r', encoding='UTF-8') as t:
FileNotFoundError: [Errno 2] No such file or directory: '2D\\CarboKlev\\1\\CarboKlev_1_OriValues.txt'
答案 0 :(得分:0)
好的,我想找到了问题所在。
如果我在Google Colab中使用matplotlib.image.imread()
,它将关闭,它在路径中仅支持/
,而不支持\\
,我不知道为什么。