【发布时间】:2020-09-08 01:33:38
【问题描述】:
我正在尝试在 Google Colab 上运行 TensorFlow Object Detection API 以在自定义数据集上训练 SSD-Mobilenet 模型。但我正面临这个 NoModuleError。它没有找到模块'nets'。我已经发现有人面临类似的问题,尽管他们没有在 Google Colab 中运行 trining。以下是部分链接:
ImportError: No module named 'nets'
ModuleNotFoundError: No module named 'nets' (TensorFlow)
我在上面的任何地方都找到了添加slim 和research 文件夹的PYTHONPATH 的建议,我都做了。以下是我已经添加的路径:
! echo $PYTHONPATH
import os
os.environ['PYTHONPATH'] += ":/models"
os.environ['PYTHONPATH'] += ":/models/research"
os.environ['PYTHONPATH'] += ":/models/research/slim"
# I copied the `nets` folder inside models folder and
# additionally here adding this folder to python path such that it becomes available to `faster_rcnn_inception_resnet_v2_feature_extractor.py` file for importing.
os.environ['PYTHONPATH'] += ":/models/nets"
! echo $PYTHONPATH
%cd '/content/gdrive/My Drive/Computer_vision_with_deep_learning/TFOD/models/research/'
!python setup.py build
!python setup.py install
%cd '/content/gdrive/My Drive/Computer_vision_with_deep_learning/TFOD'
但仍然出现此错误。以下是我在 Colab 上遇到的错误:
Traceback (most recent call last):
File "training/train.py", line 26, in <module>
from object_detection import model_lib
File "/content/gdrive/My Drive/Computer_vision_with_deep_learning/TFOD/training/object_detection/model_lib.py", line 28, in <module>
from object_detection import exporter as exporter_lib
File "/content/gdrive/My Drive/Computer_vision_with_deep_learning/TFOD/training/object_detection/exporter.py", line 23, in <module>
from object_detection.builders import model_builder
File "/content/gdrive/My Drive/Computer_vision_with_deep_learning/TFOD/training/object_detection/builders/model_builder.py", line 59, in <module>
from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
File "/content/gdrive/My Drive/Computer_vision_with_deep_learning/TFOD/training/object_detection/models/faster_rcnn_inception_resnet_v2_feature_extractor.py", line 30, in <module>
from nets import inception_resnet_v2
ModuleNotFoundError: No module named 'nets'
正如我注意到的错误产生行是文件faster_rcnn_inception_resnet_v2_feature_extractor.py 的from nets import inception_resnet_v2。因此,我还在其范围内复制了nets 文件夹,以便它可以找到该模块。但它仍然在说同样的事情,尽管现在不应该找到这个模块是没有意义的。这里可能还有什么问题?
【问题讨论】:
标签: python tensorflow google-colaboratory pythonpath