Attribute Error when trying to run for training in Google Colab

I am training for Object Detection using the Tensorflow Object Detection API Tutorial. here is the link:Tensorflow Object Detetction Docs Tutorial
but I am getting an error when I run: !python --model_dir=/content/drive/MyDrive/colab/Tensorflow/workspace/training_demo/models/my_ssd_resnet50_v1_fpn --pipeline_config_path=/content/drive/MyDrive/colab/Tensorflow/workspace/training_demo/models/my_ssd_resnet50_v1_fpn/pipeline.config and after I run that script I get this error: `AttributeError: in user code:

File "/usr/local/lib/python3.10/dist-packages/object_detection/data_decoders/", line 556, in decode  *
    tensors = decoder.decode(serialized_example, items=keys)
File "/usr/local/lib/python3.10/dist-packages/tf_slim/data/", line 722, in decode  *
File "/usr/local/lib/python3.10/dist-packages/tf_slim/data/", line 405, in tensors_to_item  *
    return self._decode(image_buffer, image_format)
File "/usr/local/lib/python3.10/dist-packages/tf_slim/data/", line 453, in _decode  *
    image =

AttributeError: module 'tensorflow.python.ops.control_flow_ops' has no attribute 'case'`

has anyone any clue on what did I do wrong there? I followed the Tensorflow Object Detection Docs tutorial step by step but I still do not understand why is giving me that error.

Hi @Aby,In the tutorial you are following i can see that they are using a research model for your object detection training, those models contain some deprecated lines of code. TensorFlow does not officially support research models.

I recommend you to use the official tensorflow/models for your use case. Please refer to this tutorial for implementing object detection using official models and let us know if you faceing any errors? Thank you.

1 Like

Hi Kiran, Thanks for the reply. I will try it out and let you know if it solved the issue.

Hi @Aby, have you managed to fix that? I am also trying to train the ssd tensorflow model on a custom dataset in Collab, but face the same error: AttributeError: module ‘tensorflow.python.ops.control_flow_ops’ has no attribute ‘case’. I also used research models. I couldn’t find the ssd nodel among the official models. Thank you for your reply!

to fix this problem if you’re using Ubuntu:

open this file :

home > user > .local > lib > python3.11 > site-packages > tf_slim > data >

first, add import tensorflow as tf at the top, then change these parts of the code

at line 453 instead of

image =, default=check_jpeg, exclusive=True)

put this

image =, default=check_jpeg, exclusive=True)

and other places if used control_flow_ops put tf instead.

1 Like

thanks, that solved it, 2-3 more places to replace the obsoluete control_flow_ops. Not sure where this conflict arose.

this conflict is because tf 2.14 to later version removed case attribute from ‘tensorflow.python.ops.control_flow_ops’ module, we have to use this from tensorflow
not from ‘tensorflow.python.ops.control_flow_ops’. that’s why we replaced
thank you!