問題描述
為什麼當我安裝了 Tensorflow 的所有庫後,會出現無目錄錯誤? (Why do I get a no directory error, when I have installed all the libraries for 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 中安裝了所有庫,所以我不明白為什麼會出現此錯誤或如何修復它。任何幫助將不勝感激。
參考解法
方法 1:
I am able to recreate your issue in 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
Output:
[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
Solution: To fix this issue, you can change your current directory /content
to /root/models/research
by including below two lines before running your code.
%cd
!git clone ‑‑quiet https://github.com/tensorflow/models.git
Here is the updated code
%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
Output:
/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
(by Swalkr、Tensorflow Warrior)