0

I have skimmed through the internet for a couple of days but found no working solution for this problem. I'm training an image dataset using the Tensorflow Object Detection API on the GCloud. My job keeps failing, citing this error. I have the latest protobuf version installed, I have performed this code as well (proposed as a soluiton in some cases):

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

I've done everything as instructed but my job keeps failing.

This is the error log in detail:

Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", 
line 174, in _run_module_as_main "__main__", fname, loader, pkg_name)     
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in 
run_globals File "/root/.local/lib/python2.7/site- 
packages/object_detection/train.py", line 49, in <module> from 
object_detection import trainer File "/root/.local/lib/python2.7/site- 
packages/object_detection/trainer.py", line 27, in <module> from 
object_detection.builders import preprocessor_builder File 
"/root/.local/lib/python2.7/site- 
packages/object_detection/builders/preprocessor_builder.py", line 21,  
in <module> from object_detection.protos import preprocessor_pb2 
ImportError: cannot import name preprocessor_pb2

Update: I performed the same procedure, with the same packages to train the data locally on my CPU and it worked without any errors. So maybe it is a problem with GCloud.

Jai Kotia
  • 166
  • 2
  • 16
  • The error is coming from the "installed" version of object detection "lib/python2.7/site- packages/object_detection/builders/preprocessor_builder.py". Most likely the compiled proto files are in your repo folder, which is not on PYTHONPATH. – iga Jun 23 '18 at 04:37
  • I have performed this as well though: "export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim" – Jai Kotia Jun 23 '18 at 06:22
  • This is strange. If you have root access, I would suggest to just edit your `/root/.local/lib/python2.7/site-packages/object_detection/builders/preprocessor_builder.py` file to add `import pdb; pdb.set_trace()` before the failing import. Then, debug why the import is not working. For example, the directories you added to PYTHONPATH should appear in `sys.path`. Don't forget to remove your edits afterwards :). – iga Jun 26 '18 at 01:59
  • Is this issue still happening? What runtime version did you use? – Héctor Neri Oct 25 '18 at 22:01

1 Answers1

2

I have had this error many times, each time i forgot to run the command or run it from correct folder

You have to run the commands from the correct folder

For example, If you are on windows OS, From the command prompt change directory to research(parent of object_detection) Folder run the following. Change the commands accordingly based on the OS you are on

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

2) SET PYTHONPATH=%cd%;%cd%\slim

Then launch the notebook from same command line and try to run.

Srinivas Bringu
  • 452
  • 3
  • 9
  • As I mentioned, I have followed this procedure several times and ran those commands as documented from the correct folder but the errors persisted – Jai Kotia Jul 14 '18 at 11:53
  • `set PYTHONPATH=C:\tensorflow1\models;C:\tensorflow1\models\research;C:\tensorflow1\models\research\slim` – lovechillcool Jul 14 '20 at 20:08