1

Hi I am doing tensorflow object detection api. I have followed all major instructions in the repo and it had been working fine until now.But some weird error is starting to pop upm suddenly. I was using fast rcnn earlier and now switched to ssd mobile v2 coco.

While generating inference graph using command

python export_inference_graph.py --input_type image_tensor --pipeline_config_path training/faster_rcnn_inception_v2_pets.config --trained_checkpoint_prefix training/model.ckpt-10250 --output_directory inference_graph

I get the following errror:

Traceback (most recent call last): File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call return fn(*args) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.NotFoundError: Key Conv/biases not found in checkpoint [[{{node save/RestoreV2}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1286, in restore {self.saver_def.filename_tensor_name: save_path}) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 950, in run run_metadata_ptr) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1173, in _run feed_dict_tensor, options, run_metadata) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1350, in _do_run run_metadata) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1370, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.NotFoundError: Key Conv/biases not found in checkpoint [[node save/RestoreV2 (defined at /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py:331) ]]

Original stack trace for 'save/RestoreV2': File "export_inference_graph.py", line 162, in tf.app.run() File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/absl/app.py", line 299, in run _run_main(main, args) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "export_inference_graph.py", line 158, in main write_inference_graph=FLAGS.write_inference_graph) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py", line 497, in export_inference_graph write_inference_graph=write_inference_graph) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py", line 426, in _export_inference_graph trained_checkpoint_prefix=checkpoint_to_use) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py", line 331, in write_graph_and_checkpoint tf.import_graph_def(inference_graph_def, name='') File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 443, in import_graph_def _ProcessNewOps(graph) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 236, in _ProcessNewOps for new_op in graph._add_new_tf_operations(compute_devices=False): # pylint: disable=protected-access File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3751, in _add_new_tf_operations for c_op in c_api_util.new_tf_operations(self) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3751, in for c_op in c_api_util.new_tf_operations(self) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3641, in _create_op_from_tf_operation ret = Operation(c_op, self) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2005, in init self._traceback = tf_stack.extract_stack()

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1296, in restore names_to_keys = object_graph_key_mapping(save_path) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1614, in object_graph_key_mapping object_graph_string = reader.get_tensor(trackable.OBJECT_GRAPH_PROTO_KEY) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 678, in get_tensor return CheckpointReader_GetTensor(self, compat.as_bytes(tensor_str)) tensorflow.python.framework.errors_impl.NotFoundError: Key _CHECKPOINTABLE_OBJECT_GRAPH not found in checkpoint

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "export_inference_graph.py", line 162, in tf.app.run() File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/absl/app.py", line 299, in run _run_main(main, args) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "export_inference_graph.py", line 158, in main write_inference_graph=FLAGS.write_inference_graph) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py", line 497, in export_inference_graph write_inference_graph=write_inference_graph) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py", line 426, in _export_inference_graph trained_checkpoint_prefix=checkpoint_to_use) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py", line 335, in write_graph_and_checkpoint saver.restore(sess, trained_checkpoint_prefix) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1302, in restore err, "a Variable name or other graph key that is missing") tensorflow.python.framework.errors_impl.NotFoundError: Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Key Conv/biases not found in checkpoint [[node save/RestoreV2 (defined at /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py:331) ]]

Original stack trace for 'save/RestoreV2': File "export_inference_graph.py", line 162, in tf.app.run() File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/absl/app.py", line 299, in run _run_main(main, args) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "export_inference_graph.py", line 158, in main write_inference_graph=FLAGS.write_inference_graph) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py", line 497, in export_inference_graph write_inference_graph=write_inference_graph) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py", line 426, in _export_inference_graph trained_checkpoint_prefix=checkpoint_to_use) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py", line 331, in write_graph_and_checkpoint tf.import_graph_def(inference_graph_def, name='') File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 443, in import_graph_def _ProcessNewOps(graph) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 236, in _ProcessNewOps for new_op in graph._add_new_tf_operations(compute_devices=False): # pylint: disable=protected-access File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3751, in _add_new_tf_operations for c_op in c_api_util.new_tf_operations(self) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3751, in for c_op in c_api_util.new_tf_operations(self) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3641, in _create_op_from_tf_operation ret = Operation(c_op, self) File "/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2005, in init self._traceback = tf_stack.extract_stack()

Actually it had been working rightly all the time cant figure what happenned now. I tried with fast rcnn as well(which was working earlier) but it has also started failing

Here is config file.I am doing it for 2 classes currently

# Faster R-CNN with Inception v2, configured for Oxford-IIIT Pets Dataset.
# Users should configure the fine_tune_checkpoint field in the train config as
# well as the label_map_path and input_path fields in the train_input_reader and
# eval_input_reader. Search for "PATH_TO_BE_CONFIGURED" to find the fields that
# should be configured.

model {
  faster_rcnn {
    num_classes: 2
    image_resizer {
      keep_aspect_ratio_resizer {
        min_dimension: 600
        max_dimension: 1024
      }
    }
    feature_extractor {
      type: 'faster_rcnn_inception_v2'
      first_stage_features_stride: 16
    }
    first_stage_anchor_generator {
      grid_anchor_generator {
        scales: [0.25, 0.5, 1.0, 2.0]
        aspect_ratios: [0.5, 1.0, 2.0]
        height_stride: 16
        width_stride: 16
      }
    }
    first_stage_box_predictor_conv_hyperparams {
      op: CONV
      regularizer {
        l2_regularizer {
          weight: 0.0
        }
      }
      initializer {
        truncated_normal_initializer {
          stddev: 0.01
        }
      }
    }
    first_stage_nms_score_threshold: 0.0
    first_stage_nms_iou_threshold: 0.7
    first_stage_max_proposals: 300
    first_stage_localization_loss_weight: 2.0
    first_stage_objectness_loss_weight: 1.0
    initial_crop_size: 14
    maxpool_kernel_size: 2
    maxpool_stride: 2
    second_stage_box_predictor {
      mask_rcnn_box_predictor {
        use_dropout: false
        dropout_keep_probability: 1.0
        fc_hyperparams {
          op: FC
          regularizer {
            l2_regularizer {
              weight: 0.0
            }
          }
          initializer {
            variance_scaling_initializer {
              factor: 1.0
              uniform: true
              mode: FAN_AVG
            }
          }
        }
      }
    }
    second_stage_post_processing {
      batch_non_max_suppression {
        score_threshold: 0.0
        iou_threshold: 0.6
        max_detections_per_class: 100
        max_total_detections: 300
      }
      score_converter: SOFTMAX
    }
    second_stage_localization_loss_weight: 2.0
    second_stage_classification_loss_weight: 1.0
  }
}

train_config: {
  batch_size: 1
  optimizer {
    momentum_optimizer: {
      learning_rate: {
        manual_step_learning_rate {
          initial_learning_rate: 0.0002
          schedule {
            step: 1
            learning_rate: .0002
          }
          schedule {
            step: 900000
            learning_rate: .00002
          }
          schedule {
            step: 1200000
            learning_rate: .000002
          }
        }
      }
      momentum_optimizer_value: 0.9
    }
    use_moving_average: false
  }
  gradient_clipping_by_norm: 10.0
  fine_tune_checkpoint: "/home/user/Downloads/Data_Science/Git/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt"
  from_detection_checkpoint: true
  load_all_detection_checkpoint_vars: false
  # Note: The below line limits the training process to 200K steps, which we
  # empirically found to be sufficient enough to train the pets dataset. This
  # effectively bypasses the learning rate schedule (the learning rate will
  # never decay). Remove the below line to train indefinitely.
  num_steps: 200000
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
}


train_input_reader: {
  tf_record_input_reader {
    input_path: "/home/user/Downloads/Data_Science/Git/models/research/object_detection/train.record"
  }
  label_map_path: "/home/user/Downloads/Data_Science/Git/models/research/object_detection/training/labelmap.pbtxt"
}

eval_config: {
  num_examples: 67
  # Note: The below line limits the evaluation process to 10 evaluations.
  # Remove the below line to evaluate indefinitely.
  max_evals: 10
}

eval_input_reader: {
  tf_record_input_reader {
    input_path: "C:/tensorflow1/models/research/object_detection/test.record"
  }
  label_map_path: "C:/tensorflow1/models/research/object_detection/training/labelmap.pbtxt"
  shuffle: false
  num_readers: 1
}

Found one or two similar errors in github.But its of no use. Any help would be appreciated.If you need any more information,please leave a comment.Thank you!

1 Answer 1

1

Are you sure that your model training/model.ckpt-10250 is a faster_rcnn_inception_v2_pets model? The error NotFoundError: Key Conv/biases not found in checkpoint [[{{node save/RestoreV2}}]] implies that it cannot recover Conv/biases from the checkpoint.

Alternatively make sure that you are using TF version that is supported by the object detection framework. You can find all releases here.

Sign up to request clarification or add additional context in comments.

1 Comment

I am sure with TF version as I was using it all this time.same with the case of fast rcnn

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.