Import Error for Update Config for Transfer Learning

import tensorflow as tf
from object_detection.utils import config_util
from object_detection.protos import pipeline_pb2
from google.protobuf import text_format

TypeError Traceback (most recent call last)
Cell In [22], line 2
1 import tensorflow as tf
----> 2 from object_detection.utils import config_util
3 from object_detection.protos import pipeline_pb2
4 from google.protobuf import text_format

File ~\Desktop\Tensorflow Object Detection\TFODCourse\tfod\lib\site-packages\object_detection\utils\config_util.py:28
26 from object_detection.protos import input_reader_pb2
27 from object_detection.protos import model_pb2
—> 28 from object_detection.protos import pipeline_pb2
29 from object_detection.protos import train_pb2
32 def get_image_resizer_config(model_config):

File ~\Desktop\Tensorflow Object Detection\TFODCourse\tfod\lib\site-packages\object_detection\protos\pipeline_pb2.py:22
18 import object_detection.protos.model_pb2
19 import object_detection.protos.train_pb2
—> 22 DESCRIPTOR = _descriptor.FileDescriptor(
23 name=‘object_detection/protos/pipeline.proto’,
24 package=‘object_detection.protos’,
25 serialized_pb=_b(’\n&object_detection/protos/pipeline.proto\x12\x17object_detection.protos\x1a"object_detection/protos/eval.proto\x1a*object_detection/protos/input_reader.proto\x1a#object_detection/protos/model.proto\x1a#object_detection/protos/train.proto"\xca\x02\n\x17TrainEvalPipelineConfig\x12\x36\n\x05model\x18\x01 \x01(\x0b\x32’.object_detection.protos.DetectionModel\x12:\n\x0ctrain_config\x18\x02 \x01(\x0b\x32$.object_detection.protos.TrainConfig\x12@\n\x12train_input_reader\x18\x03 \x01(\x0b\x32$.object_detection.protos.InputReader\x12\x38\n\x0b\x65val_config\x18\x04 \x01(\x0b\x32#.object_detection.protos.EvalConfig\x12?\n\x11\x65val_input_reader\x18\x05 \x01(\x0b\x32$.object_detection.protos.InputReader’)
26 ,
27 dependencies=[object_detection.protos.eval_pb2.DESCRIPTOR,object_detection.protos.input_reader_pb2.DESCRIPTOR,object_detection.protos.model_pb2.DESCRIPTOR,object_detection.protos.train_pb2.DESCRIPTOR,])
28 _sym_db.RegisterFileDescriptor(DESCRIPTOR)
33 _TRAINEVALPIPELINECONFIG = _descriptor.Descriptor(
34 name=‘TrainEvalPipelineConfig’,
35 full_name=‘object_detection.protos.TrainEvalPipelineConfig’,
(…)
87 serialized_end=552,
88 )

File ~\Desktop\Tensorflow Object Detection\TFODCourse\tfod\lib\site-packages\google\protobuf\descriptor.py:982, in FileDescriptor.new(cls, name, package, options, serialized_options, serialized_pb, dependencies, public_dependencies, syntax, pool, create_key)
980 raise RuntimeError(‘Please link in cpp generated lib for %s’ % (name))
981 elif serialized_pb:
→ 982 return _message.default_pool.AddSerializedFile(serialized_pb)
983 else:
984 return super(FileDescriptor, cls).new(cls)

TypeError: Couldn’t build proto file into descriptor pool!
Invalid proto descriptor for file “object_detection/protos/pipeline.proto”:
object_detection/protos/model.proto: Import “object_detection/protos/model.proto” has not been loaded.
object_detection.protos.TrainEvalPipelineConfig.model: “.object_detection.protos.DetectionModel” is not defined.

Install protos before using Object Detection API

# Install the Object Detection API
%%bash
cd models/research/
protoc object_detection/protos/*.proto --python_out=.
cp object_detection/packages/tf2/setup.py .
python -m pip install .

Thank you!

I tried this and I got error. Couldn’t find program: ‘bash’. Should I pip install bash?

No, the code will be executed by bash.

Can you please share details of the operating system?

@James_Justus

%%bash is magic command in colab, it will not work generally on your personal environment. Please make sure to run each of them in command line of the environment. Inside jupyter notebook you can run the same by putting ! before each command as follows:

# Install the Object Detection API
!cd models/research/
!protoc object_detection/protos/*.proto --python_out=.
!cp object_detection/packages/tf2/setup.py .
!python -m pip install .