Search code examples
tensorflowobject-detection-api

tf-1.5 or tf-2.1 when running object detection training


When I tried to run:

From the tensorflow/models/research/ directory

PIPELINE_CONFIG_PATH=/home/paul/objdetect/models/research/object_detection/samples/configs/ssdlite_mobilenet_v3_small_320x320_kitti.config
MODEL_DIR=/home/paul/objdetect/models/research/object_detection/samples/sample_model_ckpt/
NUM_TRAIN_STEPS=5000
SAMPLE_1_OF_N_EVAL_EXAMPLES=1
python object_detection/model_main.py \
    --pipeline_config_path=${PIPELINE_CONFIG_PATH} \
    --model_dir=${MODEL_DIR} \
    --num_train_steps=${NUM_TRAIN_STEPS} \
    --sample_1_of_n_eval_examples=$SAMPLE_1_OF_N_EVAL_EXAMPLES \
    --alsologtostderr

if I use tensorflow-gpu==1.5.0 environment, I got following error:

    from nets import inception_resnet_v2
  File "/home/paul/objdetect/models/research/slim/nets/inception_resnet_v2.py", line 375, in <module>
    batch_norm_updates_collections=tf.compat.v1.GraphKeys.UPDATE_OPS,
AttributeError: 'module' object has no attribute 'v1'

Then I switch to tensorflow-gpu==2.1.0 environment, and run it again, I got the following error:

    from object_detection import eval_util
  File "/home/paul/objdetect/models/research/object_detection/eval_util.py", line 40, in <module>
    slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'

So is there a way to run it at all? what do I need to fix to get it running either in tf-1.5 or tf-2.1?

Anyone could help? Thank you very much in advance.

Sincerely yours,

-Paul


Solution

  • tf.contrib has been deprecated in tf2.x. Similarly tf.compat was introduced in the 1.14.x and 1.15.x for solving compatability between tf 1.x and tf2.x. Try to install tensorflow version 1.15.x and run