当我安装了Tensorflow的所有库时,为什么会出现无目录错误?

2024-05-23 17:11:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在学习本教程:https://github.com/RomRoc/objdet_train_tensorflow_colab/blob/master/objdet_custom_tf_colab.ipynb

当我尝试运行第一段代码时:


!apt-get install -qq protobuf-compiler python-tk

!pip install -q Cython contextlib2 pillow lxml matplotlib PyDrive

!pip install -q pycocotools

%cd ~/models/research
!protoc object_detection/protos/*.proto --python_out=.

import os
os.environ['PYTHONPATH'] += ':/content/models/research/:/content/models/research/slim/'

!python object_detection/builders/model_builder_test.py

我得到这个错误:

/content
object_detection/protos/*.proto: No such file or directory
python3: can't open file 'object_detection/builders/model_builder_test.py': [Errno 2] No such file or directory

正如教程所说,我已经在GoogleColab中安装了所有的库,所以我不明白为什么会出现这个错误,或者如何修复它。任何帮助都将不胜感激


Tags: installpipobjectosmodels教程contentfile
1条回答
网友
1楼 · 发布于 2024-05-23 17:11:29

我可以在Google Colab中重新创建您的问题

!apt-get install -qq protobuf-compiler python-tk

!pip install -q Cython contextlib2 pillow lxml matplotlib PyDrive

!pip install -q pycocotools

%cd ~/models/research
!protoc object_detection/protos/*.proto  python_out=.

import os
os.environ['PYTHONPATH'] += ':/content/models/research/:/content/models/research/slim/'

!python object_detection/builders/model_builder_test.py

输出:

[Errno 2] No such file or directory: '/root/models/research'
/content
object_detection/protos/*.proto: No such file or directory
python3: can't open file 'object_detection/builders/model_builder_test.py': [Errno 2] No such file or directory

解决方案:要解决此问题,您可以在运行代码之前,通过包含以下两行代码,将当前目录/content更改为/root/models/research

%cd
!git clone  quiet https://github.com/tensorflow/models.git

这是更新后的代码

%cd

!git clone  quiet https://github.com/tensorflow/models.git

!apt-get install -qq protobuf-compiler python-tk

!pip install -q Cython contextlib2 pillow lxml matplotlib PyDrive

!pip install -q pycocotools

%cd ~/models/research
!protoc object_detection/protos/*.proto  python_out=.

import os
os.environ['PYTHONPATH'] += ':/content/models/research/:/content/models/research/slim/'

!python object_detection/builders/model_builder_test.py

输出:

/root
/root/models/research
2020-05-08 15:23:47.035256: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1

相关问题 更多 >