Closed tcexeexe closed 3 years ago
I apologize but I am having a hard time understanding what the problem is, where the problem is, and what version it affects. Please resubmit and pay attention to the issue template (https://github.com/tensorflow/tensorflow/issues/new) . Please provide all the information it asks. Thank you.
In particular, detailed instructions to reproduce the problem will be most helpful.
As of now, it is not clear to me whether the notebook file is in the expected directory from where it can access all the libraries. (From your log it seems you're using some file called example.py
, where is that coming from? There is no such file in the object_detection
directory)
I have the same question You can change label_map_util.py (in utils folder) line 22 to from protos import string_int_label_map_pb2.
I have faced the same error: I found out that I only get it when running my commands from another directory than the project root directory.
To see if you installed the API correctly, you can run the following command from the tensorflow/models directory:
python object_detection/protos/label_map_util_test.py
It should print out OK.
Edit: There are indentation errors in the test file from line 79-107
Hi, I solve this just 1) git clone https://github.com/tensorflow/models in tensorflow folder.
2) protoc object_detection/protos/*.proto --python_out=.
3)# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:pwd
:pwd
/slim
I have faced the same error: ImportError: cannot import name 'label_map_util' so The file in ‘object_detection/utils’
After cloning tensorflow models, running protoc object_detection/protos/*.proto --python_out=.
and exporting PYTHONPATH it still failed but changing the import helped:
from object_detection.utils import label_map_util
I have faced the same error: ImportError: cannot import name 'label_map_util' i just install setup.py in research folder and i copied that object_detection and .egg.info in sitepackages folder
I tried running these commands as mentioned from a jupyter notebook:
git clone https://github.com/tensorflow/models in tensorflow folder.
From tensorflow/models/research/
protoc object_detection/protos/*.proto --python_out=.
3)# From tensorflow/models/research/ export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim
but it still doesnot work
This seems to be coming up very frequently - make sure object_detection
is in your PYTHONPATH
!
My system is windows 10, python 3.6 and I install protoc-3.4.0-win32 not protoc-3.5.0-win32, protoc-3.5 for windows has bug!!!
After running protoc object_detection/protos/*.proto --python_out=.
just change
from utils import label_map_util
to
from object_detection.utils import label_map_util
I am facing issue in windows 10 ,python 3.6 in object detection can any one help me out these, i am facing errors as name 'label_map_util' is not defined & No module named 'utils'
I am facing the same problem right now from utils import label_map_util
ModuleNotFoundError: No module named 'utils'
It mostly happens if you've changed the working directory,so you need to add it to the PATH
I am faceing issue in Mac ,python 3.5.6. I add the path ,but it still doesn't work , I try to do it. like : export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim
so,not working . I ask question for my teacher, so he tell me the Mac operating system is ‘Unix’,unlike linux。 Every time I do this, it doesn't work。
@Viveco what's the protoc version that you're using?
import like this...
from object_detection.utils import label_map_util
@parmarmanoj007 still does not work :(
Note that the object_detection
directory needs to be in PYTHONPATH, not its parent.
I tried all of the methods from internet and they didn't work. At last, I solve this problem on mac: My pip3 and python3 were not matched. I solve this just:
I'm also getting same error.
from object_detection.utils import label_map_util
File "/usr/local/lib/python2.7/dist-packages/object_detection-0.1-py2.7.egg/object_detection/utils/label_map_util.py", line 21, in
protoc object_detection/protos/*.proto --python_out=.
it is not recognizing fo me, I am using Windows 7
PS D:\TensorFlow_Supporting\models-master\research> python object_detection/builders/model_builder_test.py
Traceback (most recent call last):
File "object_detection/builders/model_builder_test.py", line 23, in
I solved my problem.
PYTHONPATH D:\TensorFlow_Supporting\modelsmaster\research\slim;D:\TensorFlow_Supporting\models-maste
here not " \ research " HAHAHA.....
Hi guys.Please help me.
if i run object_detection_toturial code with protobuf=3.0.0 i get this error: serialized_pb=_b('\n,tensorflow/core/framework/tensor_shape.proto\x12\ntensorflow\"z\n\x10TensorShapeProto\x12-\n\x03\x64im\x18\x02 \x03(\x0b\x32 .tensorflow.TensorShapeProto.Dim\x12\x14\n\x0cunknown_rank\x18\x03 \x01(\x08\x1a!\n\x03\x44im\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\tBq\n\x18org.tensorflow.frameworkB\x11TensorShapeProtosP\x01Z=github.com/tensorflow/tensorflow/tensorflow/go/core/framework\xf8\x01\x01\x62\x06proto3') TypeError: new() got an unexpected keyword argument 'serialized_options'
and if i run code with protobuf=3.6.1 i get this:
ModuleNotFoundError: No module named 'object_detection.utils'; 'object_detection' is not a package
i set export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim too. please help i am very confused
'object_detection' is not a package ;I think that you should to add init.py in the folder,
'object_detection' is not a package ;I think that you should to add init.py in the folder,
i have it
PYTHONPATH = $ PYTHONPATH:pwd:pwd / slim ; another :PYTHONPATH = $ PYTHONPATH:。。。。/(Folder Name of "object_detection's Upper Level)?
PYTHONPATH = $ PYTHONPATH:pwd:pwd / slim ; another :PYTHONPATH = $ PYTHONPATH:。。。。/(Folder Name of "object_detection's Upper Level)?
Folder name of object_detection's Upper Level is research.and i run PYTHONPATH = $ PYTHONPATH:pwd:pwd / slim in this directoy
I tried running these commands as mentioned from a jupyter notebook:
git clone https://github.com/tensorflow/models in tensorflow folder.
From tensorflow/models/research/
protoc object_detection/protos/*.proto --python_out=.
3)# From tensorflow/models/research/ export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim
but it still doesnot work
me too.did you find a solution?
PYTHONPATH = $ PYTHONPATH:。。。。/models ; NOT‘s PYTHONPATH = $ PYTHONPATH:。。。。/models/research ; maybe,i'm not sure。
PYTHONPATH = $ PYTHONPATH:。。。。/models ; NOT‘s PYTHONPATH = $ PYTHONPATH:。。。。/models/research ; maybe,i'm not sure。
but i have slim in research directory.it should not be wrong
I solved my problem. PYTHONPATH D:\TensorFlow_Supporting\modelsmaster\research\slim;D:\TensorFlow_Supporting\models-maste ;
应该有两个路经吧,。。。/slim ;。。。/models ;
Hi, you have to do the following commands to make it work for you :
protoc object_detection/protos/*.proto --python_out=.
Add the following to your ~/.bashrc :
export PYTHONPATH=$PYTHONPATH:<PATH_TO_TF>/TensorFlow/models/research/object_detection:<PATH_TO_TF>/TensorFlow/models/research:<PATH_TO_TF>/TensorFlow/models/research/slim
I'm also getting same error.
from object_detection.utils import label_map_util File "/usr/local/lib/python2.7/dist-packages/object_detection-0.1-py2.7.egg/object_detection/utils/label_map_util.py", line 21, in from object_detection.protos import string_int_label_map_pb2 ImportError: cannot import name string_int_label_map_pb2
after running protoc object_detection\protos\string_int_label_map.proto make sure string_int_label_map_pb2.py file is created in object_detection\protos directory. I had the same problem.
protoc object_detection/protos/*.proto --python_out=.
it is not recognizing fo me, I am using Windows 7
this short command is not working in windows. so instead of *.proto in the command include all the .proto files names in the command and run it. after that validate .py file is created for each .proto files. i.e string_int_label_map_pb2.py for string_int_label_map.proto ... etc.
After cloning tensorflow models, running
protoc object_detection/protos/*.proto --python_out=.
and exporting PYTHONPATH it still failed but changing the import helped:from object_detection.utils import label_map_util
Following code is needed at the end. Otherwise it will still fail:
pip install tensorflow-object-detection-api
Resolved on a Mac, running Python 3.9.5.
sys.path.append('tensorflow/models/research/')
sys.path.append('tensorflow/models/research/object_detection/')
from utils import label_map_util
from utils import visualization_utils as vis_util
first I was able to do
from object_detection.utils import dataset_util
but I couldn't add import label_map_util
like this:
from object_detection.utils import dataset_util, label_map_util
then I tried this on windows cmd:
pip install tensorflow-object-detection-api
I can run it successfully
I'm getting an error. category_index = label_map_util.create_category_index_from_labelmap(files['LABELMAP']) name error: name 'label_map_util' is not defined
l follow the Installation step to install in python2.7,debian 8 and pass the "model_builder_test.py" but when l run the Object Detection Demo,the error happend:
root@australia_debian1:~/PycharmProjects/objdetection# ipython example.py
ImportError Traceback (most recent call last) /root/PycharmProjects/objdetection/example.py in()
17 # This is needed since the notebook is stored in the object_detection folder.
18 sys.path.append("..")
---> 19 from utils import label_map_util
20
21 from utils import visualization_utils as vis_util
ImportError: cannot import name label_map_util
dose anyone know how to solve this problem?