models icon indicating copy to clipboard operation
models copied to clipboard

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

Open hammadullah125 opened this issue 8 years ago • 34 comments

Hey. I'm trying to run train.py from models/research/object_detection/legacy but it's throwing this error

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

I did the following as well but no luck

From tensorflow/models/research/ protoc object_detection/protos/*.proto --python_out=.

From tensorflow/models/research/ export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

PS: I also run the model_main.py from models/research/object_detection but the same error.

hammadullah125 avatar Sep 07 '18 09:09 hammadullah125

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. What is the top-level directory of the model you are using Have I written custom code OS Platform and Distribution TensorFlow installed from TensorFlow version Bazel version CUDA/cuDNN version GPU model and memory Exact command to reproduce

tensorflowbutler avatar Sep 07 '18 19:09 tensorflowbutler

Did you follow the setup instructions (specifically the part about compiling the protos)?

Also next time, please fill out the form!

k-w-w avatar Sep 07 '18 19:09 k-w-w

@k-w-w yeah I did follow but still this problem.

hammadullah125 avatar Sep 07 '18 19:09 hammadullah125

I've tagged this as a possible bug, can you fill out this form? What is the top-level directory of the model you are using Have I written custom code OS Platform and Distribution TensorFlow installed from TensorFlow version Bazel version CUDA/cuDNN version GPU model and memory Exact command to reproduce

k-w-w avatar Sep 08 '18 01:09 k-w-w

What is the top-level directory of the model you are using >>models/research Have I written custom code >> No OS Platform and Distribution >> Mac OS Sierra TensorFlow installed from >> pip3 installation TensorFlow version >> 1.10.1 Bazel version >> N/A CUDA/cuDNN version >> CUDA 9 GPU model and memory >> N/A Exact command to reproduce >> python3 model_main.py --logtostderr --train_dir=training/ --pipelie_config_path=training/ssd_mobilenet_v1_pets.config

hammadullah125 avatar Sep 08 '18 12:09 hammadullah125

Finally I solved the problem. In my case, it was not accessing the files from local models/research directory. I figured out that it is picking all files from site-packages/object_detection-0.1-py3.6.egg, which is a bit strange for me.

hammadullah125 avatar Sep 10 '18 10:09 hammadullah125

hammadullah125 how did you solve it? In my case as well, the files are being accessed from the site-packages/object_detection-0.1-py3.6.egg location.

llNeeleshll avatar Sep 10 '18 11:09 llNeeleshll

inside the "object_detection-0.1-py3.6.egg" directory is the "object_detection" folder. Change your directory in cmd line to that directory. "models/research/object_detection" and the "object_detection-0.1-py3.6.egg/object_detection" is the same.

hammadullah125 avatar Sep 10 '18 11:09 hammadullah125

inside the "object_detection-0.1-py3.6.egg" directory is the "object_detection" folder. Change your directory in cmd line to that directory. "models/research/object_detection" and the "object_detection-0.1-py3.6.egg/object_detection" is the same.

Heyy I am still not able to get rid of that error. Could you please explain how did you do it. Thanks

sarthakg1234 avatar Oct 04 '18 20:10 sarthakg1234

I got the same problem but I solved it. I have the pb2.py file in the folder but I can't import that. I got this problem because I didn't create PYTHONPATH variable first. So if you create that, you can solve this problem. I guss if you didn't create this, you will get into the default env, which means you get into the folder py3.6.egg

gtxDaniel avatar Nov 26 '18 07:11 gtxDaniel

if you are linux user just replace the backward splash '' to forward splash '/' during run protoc .

ParmpalGill avatar Jan 21 '19 06:01 ParmpalGill

I got the same problem but I solved it. I have the pb2.py file in the folder but I can't import that. I got this problem because I didn't create PYTHONPATH variable first. So if you create that, you can solve this problem. I guss if you didn't create this, you will get into the default env, which means you get into the folder py3.6.egg

what is the variable value??

vaibhavnarkhede12 avatar Feb 18 '19 14:02 vaibhavnarkhede12

I have the same problem.

stiv-yakovenko avatar Apr 13 '19 19:04 stiv-yakovenko

hi, check this one, run the below command from research path you can do manually

protoc --python_out=. .\object_detection\protos\calibration.proto protoc --python_out=. .\object_detection\protos\object_detection.protos and verify below video https://youtu.be/nZUxoHPFf4

Rajamohanreddyai avatar May 09 '19 04:05 Rajamohanreddyai

I used this command to solve the issue where the files are sourced from "site-packages/object_detection-0.1-py3.6.egg" rather than the local tensorflow directory.

... set PYTHONPATH=C:\tensorflow1\models;C:\tensorflow1\models\research;C:\tensorflow1\models\research
slim ...

however, it still fails with

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

after a lengthy traceback.

coxfuture avatar Jun 06 '19 00:06 coxfuture

I am stucked at this error, can anybody help me to solve this error.

ImportError: cannot import name 'flexible_grid_anchor_generator_pb2'

vishal2612200 avatar Jun 12 '19 06:06 vishal2612200

I am stucked at this error, can anybody help me to solve this error.

ImportError: cannot import name 'flexible_grid_anchor_generator_pb2'

i solved this problem by running set pythonpath command one more time.

vishal2612200 avatar Jun 12 '19 11:06 vishal2612200

does any one of you arrived to fix the issue?

DeepNeurons avatar Jun 19 '19 11:06 DeepNeurons

does any one of you arrived to fix the issue?

It occurred due to error occurred in pythonpath. Try to reset your PythonPath one more time. Most Probably it occurred due to incorrect PythonPath command. correct command example:

(tensorflow1) C:\> set PYTHONPATH=C:\tensorflow1\models;C:\tensorflow1\models\research;C:\tensorflow1\models\research\slim

(Note: Every time the "tensorflow1" virtual environment is exited, the PYTHONPATH variable is reset and needs to be set up again.)

vishal2612200 avatar Jun 20 '19 06:06 vishal2612200

I am stucked at this error, can anybody help me to solve this error.

ImportError: cannot import name 'flexible_grid_anchor_generator_pb2'

I had the same issue. My problem was that I forgot to compile the proto file flexible_grid_anchor_generator.proto .

I compiled the file (from the folder models/research) with :

(tensorflow1) C:\tensorflow1\models\research>protoc --python_out=. .\object_detection\protos\flexible_grid_anchor_generator.proto

and after that I run the scripts:

(tensorflow1) C:\tensorflow1\models\research>python setup.py build

and

(tensorflow1) C:\tensorflow1\models\research>python setup.py install

After these steps the error ImportError: cannot import name 'flexible_grid_anchor_generator_pb2' was gone

knbiro avatar Jun 26 '19 14:06 knbiro