簡體   English   中英

Google Colab 中的 Tensorflow 對象檢測錯誤:模塊“nets”沒有屬性“autograd”

[英]Tensorflow Object detection in Google Colab error: module 'nets' has no attribute 'autograd'

大家好,我正在嘗試在 google colab 中使用 TensorFlow 對自定義數據進行對象檢測,因此當我嘗試使用以下代碼進行訓練時,我使用了 TensorFlow 模型動物園:

import os
!pip install tf_slim
%cd '/content/models/research/object_detection'
os.environ['PYTHONPATH'] += '/content/models/research/object_detection'
!python /content/models/research/object_detection/legacy/train.py --train_dir=training/ -- 
 pipeline_config_path=training/ssd_mobilenet_v1_pets.config --logtostderr

我收到此錯誤:

    Requirement already satisfied: tf_slim in /usr/local/lib/python3.6/dist-packages (1.1.0)
Requirement already satisfied: absl-py>=0.2.2 in /usr/local/lib/python3.6/dist-packages (from tf_slim) (0.10.0)
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from absl-py>=0.2.2->tf_slim) (1.15.0)
/content/models/research/object_detection
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
  * https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

Traceback (most recent call last):
  File "/content/try/models/research/object_detection/legacy/train.py", line 53, in <module>
    from object_detection.builders import model_builder
  File "/usr/local/lib/python3.6/dist-packages/object_detection/builders/model_builder.py", line 35, in <module>
    from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
  File "/usr/local/lib/python3.6/dist-packages/object_detection/models/faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in <module>
    from nets import inception_resnet_v2
  File "/usr/local/lib/python3.6/dist-packages/nets/__init__.py", line 5, in <module>
    from nets.autograd import Hook, Parameter
  File "/usr/local/lib/python3.6/dist-packages/nets/autograd/__init__.py", line 3, in <module>
    from .functional import *
  File "/usr/local/lib/python3.6/dist-packages/nets/autograd/functional.py", line 15, in <module>
    import nets.autograd.function as fc
AttributeError: module 'nets' has no attribute 'autograd'

我在想,也許我沒有在模型目錄中安裝所有東西,但我使用了setup.py並運行了它。

很高興為您解答,謝謝

我在本地安裝時遇到了同樣的問題。 這是因為你可能做了

pip install nets

這會安裝一個名為nets的錯誤模塊。 你應該做的是

pip uninstall nets

然后轉到文件夾research/slim並刪除整個文件夾 build。 然后在這個文件夾中執行

python setup install

那么你不應該再有這個問題了,因為使用了來自slim文件夾的nets

在 Windows 上,我還需要將PYTHONPATH環境變量設置為research文件夾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM