问题
I am using Tensorflow Object Detection API to train my object detection model. I accumulated the dataset, and am going through the this tutorial.
Everything went fine until I tried to train my dataset. When I run the following line on terminal,
python train.py --logtostderr \
--train_dir=training/ \
--pipeline_config_path=training/ssd_mobilenet_v1_coco.config
I get the following error
Traceback (most recent call last):
File "legacy/train.py", line 49, in <module>
from object_detection.builders import dataset_builder
File "/usr/local/lib/python2.7/dist-packages/object_detection-0.1-
py2.7.egg/object_detection/builders/dataset_builder.py", line 27, in
<module>
from object_detection.data_decoders import tf_example_decoder
File "/usr/local/lib/python2.7/dist-packages/object_detection-0.1-
py2.7.egg/object_detection/data_decoders/tf_example_decoder.py", line
24, in <module>
from object_detection.protos import input_reader_pb2
ImportError: cannot import name input_reader_pb2
I tried searching through sites and comments, but unfortunately couldn't get around, could anyone please help out!
Thank You!
回答1:
I figured out the answer. I was using protoc version 3.0.0(protobuf compiler) which is in beta testing mode and has some bugs. So the first check for protobuf version using
proto --version
if it libprotoc 3.0.0, purge it and install 2.6.1 once done that,
cd models/research
protoc object_detection/ --python.out=.
now it should work!
回答2:
To solve the 'Unknown flag' error reported in comment
use protoc object_detection/protos/*.proto --python_out=.
The previous answer misspelled with '. ' in python'.'out
来源:https://stackoverflow.com/questions/52456770/import-error-cannot-import-name-input-reader-pb2