Skip to main content
 首页 » 编程设计

python之导入错误 : cannot import name 'input_reader_pb2'

2025年05月04日9mfrbuaa

正在使用 win10 64 位

当我尝试通过 E:\projectx\model-master\models-master>python train.py --logtostderr --train_dir=training/--pipeline_config_path=training/ssd_mobilenet_v1_pets.config

出现这个错误

File "train.py", line 49, in from object_detection.builders import dataset_builder File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\builders\dataset_builder.py", line 27, in from object_detection.data_decoders import tf_example_decoder File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\data_decoders\tf_example_decoder.py", line 27, in from object_detection.protos import input_reader_pb2 ImportError: cannot import name 'input_reader_pb2'

我运行 protoc 3.4 protoc object_detection/protos/*.proto --python_out=. 但错误仍然存​​在 我检查了所有东西,它应该没问题并且可以工作,这让我很生气!!

请帮忙.... 谢谢

请您参考如下方法:

因为您已经在 object_detection/protos/ 中编译了所有 .proto 文件。您应该会看到包含“_pb2”的 python 文件,例如 eval_pb2。如果你能看到这些,然后转到 models/research 目录并一个一个地运行这些代码:

python setup.py build 
python setup.py install