ModuleNotFoundError:没有名为“ object_detection.protos”的模块

时间:2020-09-14 05:07:21

标签: python tensorflow

我按照说明(https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html)安装Tensorflow对象检测API。我在ubuntu18.4上使用了Anaconda,说明中的所有步骤似乎都可以完成。

当我使用以下命令训练模型时:

python model_main_tf2.py --model_dir=models/my_ssd_resnet50_v1_fpn --pipeline_config_path=models/my_ssd_resnet50_v1_fpn/pipeline.config

我收到以下错误:

Traceback (most recent call last):
  File "model_main_tf2.py", line 34, in <module>
    from object_detection import model_lib_v2
  File "/home/chanitda/Desktop/Tensorflow/workspace/training_demo/object_detection/__init__.py", line 28, in <module>
    from object_detection import eval_util
  File "/home/chanitda/Desktop/Tensorflow/workspace/training_demo/object_detection/eval_util.py", line 35, in <module>
    from object_detection.metrics import coco_evaluation
  File "/home/chanitda/Desktop/Tensorflow/workspace/training_demo/object_detection/metrics/coco_evaluation.py", line 28, in <module>
    from object_detection.utils import object_detection_evaluation
  File "/home/chanitda/Desktop/Tensorflow/workspace/training_demo/object_detection/utils/object_detection_evaluation.py", line 46, in <module>
    from object_detection.utils import label_map_util
  File "/home/chanitda/Desktop/Tensorflow/workspace/training_demo/object_detection/utils/label_map_util.py", line 30, in <module>
    from object_detection.protos import string_int_label_map_pb2
ModuleNotFoundError: No module named 'object_detection.protos'

我收到标题中提到的错误。如果有人可以帮助我提供代码示例来解决问题,我将非常感激。

1 个答案:

答案 0 :(得分:0)

从这里https://github.com/tensorflow/models/blob/master/research/object_detection/colab_tutorials/eager_few_shot_od_training_tf2_colab.ipynb开始尝试。

# Install the Object Detection API
%%bash
cd models/research/
protoc object_detection/protos/*.proto --python_out=.
cp object_detection/packages/tf2/setup.py .
python -m pip install .

或者从此处重试安装步骤,

https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#install-the-object-detection-api