0
votes

I am trying to train a model using Tensorflow 2 as written here: https://colab.research.google.com/drive/1sLqFKVV94wm-lglFq_0kGo2ciM0kecWD#scrollTo=fF8ysCfYKgTP&uniqifier=1

But when I run: python object_detection/builders/model_builder_tf2_test.py This error is returned to me: ImportError: cannot import name 'anchor_generator_pb2' from 'object_detection.protos'

I was looking for answers with such a problem on the internet. Everywhere there are two answers - either "pip install" is missing, or you need to use protoc 3.4. But that doesn't work for me. i tried versions protoc 3.17 and 3.4, It does not help. Please tell me how you can solve this problem.

2
What exactly have you tried? Did you install the dependencies as outlined in your link? - gshpychka
I did everything that is written. git clone --depth 1 github.com/tensorflow/models protoc object_detection/protos/*.proto --python_out=. cp object_detection/packages/tf2/setup.py . python -m pip install . - SergRKrus

2 Answers

0
votes

I solved the problem. It turned out that python was trying to import files from a different directory. I moved the project to this folder and it worked.

I spent 2 days solving this problem. If anyone has the same problem, take a close look at where the import fails.

0
votes

I am also encountering the same problem. In my case I don't think it is the directory.

1 VERIFICATION_SCRIPT = os.path.join(paths['APIMODEL_PATH'], 'research', 'object_detection', 'builders', 'model_builder_tf2_test.py')

I downloaded TF Models Pretrained Models from Tensorflow Model Zoo and Installed TFOD. I wanted to verify the installation. Tensorflow Model Zoo installation verification and I got the error.

ImportError: cannot import name 'anchor_generator_pb2' from 'object_detection.protos'

I still have not solved it yet. Any suggestions?