3

working on win10 64-bit

when i trying to train my model by E:\projectx\model-master\models-master>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config

this error appear

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'

i do run protoc 3.4 protoc object_detection/protos/*.proto --python_out=. but the error still exist i check all thing and it is should be fine and work, it is going me mad!!

please help.... thanks

Mohammad
  • 1,549
  • 1
  • 15
  • 27

4 Answers4

0

As you already compiled all .proto files in object_detection/protos/ . You should see python files which have '_pb2' like eval_pb2. If you can see these then go to models/research directory and run these code one by one:

python setup.py build
python setup.py install
0

From inside the object_detection folder:

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

This command will generate a *_pb2.py for each .proto file in the object_detection/protos/ folder.


Note: Is important to specify a path above object_detection, otherwise errors would occur, most likely:

object_detection/protos/ssd_anchor_generator.proto: File not found.

protos/anchor_generator.proto:8:1: Import "object_detection/protos/ssd_anchor_generator.proto" was not found or had errors.

protos/anchor_generator.proto:17:5: "FlexibleGridAnchorGenerator" is not defined.


If the error persists probably you are in the wrong folder, take a look at the output message to see from where it is trying to import the file and execute the command in the right directory.

As last resort: Download the object_detection module from https://github.com/tensorflow/models/tree/master/research place it in your working directory, enter it and re-execute the command above. It will surely works as local modules have import priority over sys.path.

If not, the error message would be probably different from the one reported and the problem lies on the tensorflow installation or the protobuf compiler; as here where the problem was caused by the protoc version.

other useful links: https://github.com/tensorflow/models/issues/5264

Community
  • 1
  • 1
Marco D.G.
  • 2,317
  • 17
  • 31
0

Maybe you haven't added module slim to PYTHONPATH.It can be done by running below code inside models/research directory.

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
-1

Seems that you didnt compile protobuf. For solving it:

  1. Download the latest protoc exe here: https://github.com/google/protobuf/releases (in your case should be win32)
  2. Rename that folder to "protoc"
  3. Put that folder inside models/research
  4. in models/research via console, launch:

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

I dont know exactly if that command will work on windows, but you have to be sure that you are using the protoc compiler that you downloaded (v.3.6) instead of the protoc in your enviroment.

Perona
  • 11
  • 1
    this command doesn't work on windows and even if you compile files one by one with batch files, you still will be getting the error – Stepan Yakovenko Apr 13 '19 at 19:53