Search code examples
pythontensorflowobject-detection

Exception has occurred: ImportError cannot import name 'string_int_label_map_pb2' from 'object_detection.protos'


I am facing import error in this code please help me out it is in label map utility function i dint need code to fix it i need how to solve this import error.

"""Label map utility functions."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import collections
import logging
import sys
sys.path.append('models/research/object_detection')
import numpy as np
from six import string_types
from six.moves import range
import tensorflow.compat.v1 as tf
from google.protobuf import text_format
import object_detection
from object_detection.protos import string_int_label_map_pb2

Solution

  • You just need to put that files in the same folder and just write

    import string_int_label_map_pb2
    

    instead of

    from object_detection.protos import string_int_label_map_pb2
    

    Also make sure you have converted protos files to .py file.