python - 为什么我在安装了 Tensorflow 的所有库后会出现无目录错误?
问题描述
我正在关注本教程: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
正如教程所说,我已经在 Google Colab 中安装了所有库,所以我不明白为什么会出现此错误或如何修复它。任何帮助将非常感激。
解决方案
我可以在 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
推荐阅读
- javascript - 无法将值从 C# 传递到 amcharts JavaScript 函数
- svelte - Svelte 热重载问题
- javascript - 用于匹配字符串开头和结尾的两个单引号的正则表达式
- sql - 定期从另一个数据库中的多个表更新一个数据库中的表
- arduino - 我们如何读取电源是否存在于电线中或不存在于 ardunio uno 中?
- ios - CSS 动画在 iPhone/iOS12.2 上不起作用
- javascript - data-image-src(Parallax.js)无法正常工作
- jmeter-5.0 - 标题:运行 jmeter.bat 时 JMeter 出错
- django - 如何在 django 模型中处理 auto_now_add 和 auto_now
- android - 打开 facebook 特定的帖子表单 android 应用程序