Models: Proto file issue : anchor_generator.proto

Created on 7 May 2018  路  5Comments  路  Source: tensorflow/models

When I tried to test the model from the tensorflow/models/research folder using the command below:

python object_detection/builders/model_builder_test.py

It throws out error saying import is not done.

Traceback (most recent call last):
  File "builders/model_builder_test.py", line 21, in <module>
    from object_detection.builders import model_builder
  File "D:\Workspace\Tensorflow\models\research\object_detection\builders\model_builder.py", line 17, in <module>
    from object_detection.builders import anchor_generator_builder
  File "D:\Workspace\Tensorflow\models\research\object_detection\builders\anchor_generator_builder.py", line 21, in <module>
    from object_detection.protos import anchor_generator_pb2
  File "D:\Workspace\Tensorflow\models\research\object_detection\protos\anchor_generator_pb2.py", line 27, in <module>
    dependencies=[object__detection_dot_protos_dot_grid__anchor__generator__pb2.DESCRIPTOR,object__detection_dot_protos_dot_ssd__anchor__generator__pb2.DESCRIPTOR,object__detection_dot_protos_dot_multiscale__anchor__generator__pb2.DESCRIPTOR,])
  File "C:\Users\M1043107\AppData\Local\Continuum\anaconda3\lib\site-packages\google\protobuf\descriptor.py", line 829, in __new__
    return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "object_detection/protos/anchor_generator.proto":
  object_detection/protos/anchor_generator.proto: Import "object_detection/protos/grid_anchor_generator.proto" has not been loaded.
  object_detection.protos.AnchorGenerator.grid_anchor_generator: "object_detection.protos.GridAnchorGenerator" seems to be defined in "grid_anchor_generator.proto", which is not imported by "object_detection/protos/anchor_generator.proto".  To use it here, please add the necessary import.

Though file is imported, it says not imported.
PYTHONPATH is also added - D:WorkspaceTensorflowmodelsresearch;D:WorkspaceTensorflowmodelsresearchslim;

Any solution?

Most helpful comment

Yes,I use windows. It has got all proto files in it and also compiled using protoc!
Error got resolved by setting the environment variable.

set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

All 5 comments

D:WorkspaceTensorflowmodelsresearch;D:WorkspaceTensorflowmodelsresearchslim;

Based on this line, can we assume you are on Windows? And have you compiled every single protobuf file successfully using the protoc command?

I had a similar problem before. As this guy pointed out, the short and simple protoc *.proto command from the tutorials does not work on Windows, neither does the FOR batch loop.
So we have to compile every single file separatedly, either repeating the protoc command multiple times or doing multiple protos at a time. You can try his solution, though I'd double check if there aren't any other .proto files missing from his command.

Yes,I use windows. It has got all proto files in it and also compiled using protoc!
Error got resolved by setting the environment variable.

set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
by python do you mean %PYTHONPATH% ?

https://developers.google.com/protocol-buffers/docs/reference/python-generated#cpp_impl

Check out the link. The value could be either 'python' or 'cpp'

that link also solve this problem
https://github.com/tensorflow/models/issues/1971

Was this page helpful?
0 / 5 - 0 ratings