Error with Object Detection APIs

Hi,
I am new to Tensorflow. For last couple of months I have been using Google Colab to train and evaluate Tensorflow object detection models…mainly for personal interest.
I was able to train and evaluate model with custom dataset. Suddenly today when I ran the evaluation step in same colab book, I started to get the following error.
AttributeError: module ‘tensorflow.python.ops.control_flow_ops’ has no attribute ‘case’

Here is the command for evaluation step
!python model_main_tf2.py --pipeline_config_path=/mydrive/TFODWD2/data/ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8.config --model_dir=/mydrive/TFODWD2/training/ --checkpoint_dir=/mydrive/TFODWD2/training/ --alsologtostderr

Subsequently I started to get error on loading Tensorboard as well as in training step.

Here is the link to Colab book where the steps as well as error is recorded.

The observation so far are that previously when I used to install tensorflow object detection APIs, I used to get version 2.13 for Tensorflow / Tensorboard but today I am getting version 2.14. I am not sure if the error I am getting is due to 2.14 version.
Any help will be greatly appreciated.
Thanks,
Amit

Hi @Amit_Ranjan, I can see that you 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.

Hi @Kiran_Sai_Ramineni . Thank you very much for looking into my Colab notebook and steps there. Really appreciate your guidance. I will try to follow the tutorial you mentioned above and train with official Tensorflow models.

A few follow up questions

  1. What is the reason for not loading Tensorboard
  2. Is there anyway I can use the research models the way I have been using for last two months. I mean training on version 2.13 by somehow downgrading from the current version 2.14 in Colab .

Regards,
Amit

Hi @Amit_Ranjan, For loading tensorboard could you please try by disabling the option block third-party cookies in chrome.

You can use, but you have to change the code in the .py files which is compatible with the version of tensorflow you are using. Thank You.

@Kiran_Sai_Ramineni I tried what you suggested to fix the issue with loading Tensorboard. I disables the setting in Chrome to Block Third-Party Cookies (it is now set to Allow Third Party Cookies) but it is still NOT loading. I tried opening up the colab book in Microsoft Edge Browser and there Tensorboard is loading well. So I am good with Tensorboard for now.

I will try to implement object detection with official models following the Tutorial you recommended earlier and will update you. It may take me a week or so.
Thanks again for all your help.
Amit

@Kiran_Sai_Ramineni I tried running the tutorial you suggested above for official Tensorflow Model

I am getting an error at step 'CLI command to convert data(validation data). Here is the link to colab notebook. Need some help.

Hi @Amit_Ranjan, Before running this code cell

%%bash

TRAIN_DATA_DIR='../BCC.v1-bccd.coco/train'
TRAIN_ANNOTATION_FILE_DIR='../BCC.v1-bccd.coco/train/_annotations.coco.json'
OUTPUT_TFRECORD_TRAIN='../bccd_coco_tfrecords/train'

# Need to provide
  # 1. image_dir: where images are present
  # 2. object_annotations_file: where annotations are listed in json format
  # 3. output_file_prefix: where to write output convered TFRecords files

python -m official.vision.data.create_coco_tf_record --logtostderr \
  --image_dir=${TRAIN_DATA_DIR} \
  --object_annotations_file=${TRAIN_ANNOTATION_FILE_DIR} \
  --output_file_prefix=$OUTPUT_TFRECORD_TRAIN \
  --num_shards=1

Please install tf_keras using pip install tf-keras. you won’t face this error. Thank You.

@Kiran_Sai_Ramineni Awesome. It worked. I am not getting error now and am able to complete rest of the steps in tutorial. THANK YOU very much.
I am not sure if this is the right forum to ask but the I do have a few questions on using official TensorFlow models. Please guide me who can help.

  1. Where are the config files for all the official models. I see in the tutorial that we are getting config file via exp_config = exp_factory.get_exp_config(‘retinanet_resnetfpn_coco’). Do we have a complete list of official models somewhere?
    Just for reference, for research models, all the config files are in repository (models\research\object_detection\configs\tf2)
  2. I am not able to find much documentation on official models. Most of the documentation are on research models. For example this one (and many more on youtube). It will help if someone can get us more documentation on official models.
    TensorFlow 2 Object Detection API tutorial — TensorFlow 2 Object Detection API tutorial documentation

Thanks again for your help.

Hi @Amit_Ranjan,

  1. Please find the list of experiments available here: exp_configs
  2. In tensorflow.org section model-garden has initial start for the official models and later you can refer examples under this section to deep dive and use api_docs to understand what api’s are available.

Thanks

Thank you @Kiran_Sai_Ramineni . This helps.