cannot import name 'string_int_label_map_pb2'

11,151

Solution 1

Install protoc-3.11.4 from https://github.com/google/protobuf/releases

and run protoc object_detection/protos/*.proto --python_out=. as mentioned in the installation instructions. And put this file in in object detection/protos

Solution 2

You can try this suggestion in the same order

see models/issues/1962# Or

git clone https://github.com/tensorflow/models.git
cd models/research

protoc -I=./ --python_out=./ ./object_detection/protos/*.proto
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

import sys
sys.path.append('/content/models/research/object_detection') # ~/tensorflow/models/research/object_detection

#try import now..
from utils import label_map_util
Share:
11,151

Related videos on Youtube

Sai Krishnadas
Author by

Sai Krishnadas

Updated on June 04, 2022

Comments

  • Sai Krishnadas
    Sai Krishnadas almost 2 years

    My goal is to run tensorflow object detection API and followed the steps in the installation.

    I install the tensorflow object detection API and protobuf. I have also added the path to protobuf. But the following error shoots up:

    ImportError: cannot import name 'string_int_label_map_pb2'
    

    Installed protobuf :

    %%bash
    cd models/research
    protoc object_detection/protos/*.proto --python_out=.
    

    A block of code containing the error import statements:

    from object_detection.utils import ops as utils_ops
    from object_detection.utils import label_map_util
    from object_detection.utils import visualization_utils as vis_util
    
  • Sai Krishnadas
    Sai Krishnadas about 4 years
    I run those cmds. But still the same error pop up and i use 3.6.1 version
  • Mohit Chandel
    Mohit Chandel about 4 years
    @SaiKrishnadas if this is not working then put this file in in object detection/protos
  • Mohit Chandel
    Mohit Chandel about 4 years
    @SaiKrishnadas Replace and try
  • Mohit Chandel
    Mohit Chandel about 4 years
    @SaiKrishnadas last thing I can advise is to follow this tutorial and make sure protoc-3.11.4 is installed in your Coumputer
  • Catalina Chircu
    Catalina Chircu over 3 years
    Warning: The second link you provide in your post is no longer available, you should update it.