如何修复“来自'object_detection.protos'的calibration_pb2”错误(Windows)

时间:2019-04-28 17:04:28

标签: tensorflow anaconda object-recognition

我尝试运行以下代码,但始终会给出一组错误。我尝试搜索答案,但是没有找到我的代码,有两个文件名为“ object_detection”,一个在研究文件夹中,另一个在object_detection-0.1-py3.7.egg文件夹中,这可能会导致错误,但我尝试更改路径,但错误仍然存​​在

我正在尝试执行以下命令:

C:\tensorflow1\models\research\object_detection>python train.py -- 
logtostderr --train_dir=training/ -- 
pipeline_config_path=training/faster_rcnn_inception_v2_pets.config

但出现以下错误:

Traceback (most recent call last):
1. File "train.py", line 51, in <module>
   from object_detection.builders import model_builder
2. File "C:\Users\Swayam\mypython\lib\site-packages\object_detection- 
   0.1- 
   py3.7.egg\object_detection\builders\model_builder.py", line 27, in 
   <module>
   from object_detection.builders import post_processing_builder
3. File "C:\Users\Swayam\mypython\lib\site-packages\object_detection- 
   0.1- 
   py3.7.egg\object_detection\builders\post_processing_builder.py", 
   line 2 
   2, in <module>
   from object_detection.protos import post_processing_pb2
4. File "C:\Users\Swayam\mypython\lib\site-packages\object_detection- 
   0.1- 
   py3.7.egg\object_detection\protos\post_processing_pb2.py", line 15, 
   in 
   <module>
   from object_detection.protos import calibration_pb2 as 
   object__detection_dot_protos_dot_calibration__pb2
5. ImportError: cannot import name 'calibration_pb2' from 
   'object_detection.protos' (C:\Users\Swayam\mypython\lib\site- 
packages\object_detection-0.1- 
py3.7.egg\object_detection\protos\__init__.py)

我尝试使用

protoc object_detection/protos/*.proto --python_out=.

命令,但它也会引发错误。

此外,环境不是在conda中创建的,这可能是导致错误的原因吗?尽管所有必需的安装都存在于现有的虚拟环境中。

2 个答案:

答案 0 :(得分:0)

尝试此解决方案:
检查文件
“ calibration_pb2.py”
位于以下路径中,根据您的情况,可能是以下路径:
C:\Users\Swayam\mypython\lib\site-packages\object_detection-0.1- py3.7.egg\object_detection\protos\

如果没有,只需从您的工作路径中复制它即可:
C:\tensorflow1\models\research\object_detection\protos\

如果可行,我建议您尝试将所有* pb2.py文件复制到上述路径中。

答案 1 :(得分:0)

您只需编译

protoc --python_out=. .\object_detection\protos\anchor_generator.proto .\object_detection\protos\argmax_matcher.proto .\object_detection\protos\bipartite_matcher.proto .\object_detection\protos\box_coder.proto .\object_detection\protos\box_predictor.proto .\object_detection\protos\eval.proto .\object_detection\protos\faster_rcnn.proto .\object_detection\protos\faster_rcnn_box_coder.proto .\object_detection\protos\grid_anchor_generator.proto .\object_detection\protos\hyperparams.proto .\object_detection\protos\image_resizer.proto .\object_detection\protos\input_reader.proto .\object_detection\protos\losses.proto .\object_detection\protos\matcher.proto .\object_detection\protos\mean_stddev_box_coder.proto .\object_detection\protos\model.proto .\object_detection\protos\optimizer.proto .\object_detection\protos\pipeline.proto .\object_detection\protos\post_processing.proto .\object_detection\protos\preprocessor.proto .\object_detection\protos\region_similarity_calculator.proto .\object_detection\protos\square_box_coder.proto .\object_detection\protos\ssd.proto .\object_detection\protos\ssd_anchor_generator.proto .\object_detection\protos\string_int_label_map.proto .\object_detection\protos\train.proto .\object_detection\protos\keypoint_box_coder.proto .\object_detection\protos\multiscale_anchor_generator.proto .\object_detection\protos\graph_rewriter.proto .\object_detection\protos\calibration.proto

它将解决问题