在Tensorlfow对象检测API中导出推理图时出错

斋戒

嗨,我在做tensorflow object detection api我已经按照仓库中的所有主要说明进行操作了,直到现在为止一切都很好,但是突然出现了一些奇怪的错误。我以前使用fast rcnn过,现在切换到ssd mobile v2 coco

使用命令生成推理图时

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

我得到以下错误:

追溯(最近一次呼叫最近):文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py”,行1356,在_do_call中返回fn( * args)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py”,第1341行,位于_run_fn选项,feed_dict,fetch_list,target_list, run_metadata)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py”,行1429,在_call_tf_sessionrun run_metadata中)tensorflow.python.framework.errors_impl .NotFoundError:在检查点[[{{node save / RestoreV2}}]]中找不到密钥转换/偏向

在处理上述异常期间,发生了另一个异常:

追溯(最近一次通话最近):在还原{self中,文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py”,行1286。 saver_def.filename_tensor_name:save_path})文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py”,行950,在运行run_metadata_ptr)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/client/session.py“,第1173行,在_run feed_dict_tensor中,选项,run_metadata)文件“ / home / user / anaconda3 / envs / my_env / lib / python3.6 / site-packages / tensorflow / python / client / session.py“,行1350,在_do_run run_metadata中)文件“ / home / user / anaconda3 / envs / my_env / lib / python3 .6 / site-packages / tensorflow / python / client / session.py“,第1370行,在_do_call中,抬高类型(e)(node_def,op,message)tensorflow.python.framework.errors_impl.NotFoundError:在检查点[[节点保存/ RestoreV2(在/home/user/anaconda3/envs/my_env/lib/python3.6/site-中定义包/object_detection/exporter.py:331)]]

'save / RestoreV2'的原始堆栈跟踪:tf.app.run()中的文件“ export_inference_graph.py”,第162行,文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages /tensorflow/python/platform/app.py”,第40行,运行_run(main = main,argv = argv,flags_parser = _parse_flags_tolerate_undef)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/运行_run_main(main,args)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/absl/app.py”中的第299行,位于“ site-packages / absl / app.py”行中,在_run_main sys.exit(main(argv))文件“ export_inference_graph.py”中的第250行,在主write_inference_graph = FLAGS.write_inference_graph中的第158行中)文件“ / home / user / anaconda3 / envs / my_env / lib / python3 .6 / site-packages / object_detection / exporter.py”,第497行,在export_inference_graph中,write_inference_graph = write_inference_graph中)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py”中的行426,在_export_inference_graph training_checkpoint_prefix = checkpoint_to_use)文件“ / home / user / anaconda3 / envs / my_env / lib / python3.6 / site-packages / object_detection / exporter.py“,在write_graph_and_checkpoint tf.import_graph_def(inference_graph_def,name =”'')中的第331行,文件“ / home / user / anaconda3 / envs / my_env / lib / python3.6 / site-packages / tensorflow / python / util / deprecation.py“,第507行,在new_func中返回func(* args,** kwargs)文件” / home / user / anaconda3 / envs /my_env/lib/python3.6/site-packages/tensorflow/python/framework/importer.py“,第443行,在import_graph_def _ProcessNewOps(graph)文件中/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/importer.py”,第236行,在_ProcessNewOps中,用于graph._add_new_tf_operations(compute_devices = False):# pylint:disable =受保护的访问文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”,行3751,在_add_new_tf_operations中用于c_api_util中的c_op .new_tf_operations(self)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”,行3751,用于c_api_util.new_tf_operations中的c_op( self)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”,行3641,位于_create_op_from_tf_operation ret = Operation(c_op,self)文件中“ / home / user / anaconda3 / envs / my_env / lib / python3。6 / site-packages / tensorflow / python / framework / ops.py“,第2005行,在初始化self._traceback = tf_stack.extract_stack()

在处理上述异常期间,发生了另一个异常:

追溯(最近一次通话最近):文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py”,行1296,在还原名称中_to_keys = object_graph_key_mapping (save_path)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py”,行1614,位于object_graph_key_mapping object_graph_string = reader.get_tensor(可跟踪。 OBJECT_GRAPH_PROTO_KEY)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”,在第678行,在get_tensor中,返回CheckpointReader_GetTensor(self,compat.as_bytes(tensor) )tensorflow.python.framework.errors_impl.NotFoundError:在检查点找不到键_CHECKPOINTABLE_OBJECT_GRAPH

在处理上述异常期间,发生了另一个异常:

在export_inference_graph中,write_inference_graph = write_inference_graph中)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py”中的行426,在_export_inference_graph training_checkpoint_prefix = checkpoint_to_use)文件“ / home / user / anaconda3 / envs / my_env / lib / python3.6 / site-packages / object_detection / exporter.py“,行335,位于write_graph_and_checkpoint saver.restore(sess,trained_checkpoint_prefix)文件“ / home / user / anaconda3 / envs / my_env /lib/python3.6/site-packages/tensorflow/python/training/saver.py“,行1302,在还原错误中,“缺少变量名或其他图形键”)tensorflow.python.framework.errors_impl。 NotFoundError:从检查点还原失败。这很可能是由于检查点缺少变量名或其他图形键。请确保您没有更改基于检查点的预期图形。原始错误:

在检查点[[节点保存/恢复V2(在/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py:331中定义)]中找不到关键转换/偏向

'save / RestoreV2'的原始堆栈跟踪:tf.app.run()中的文件“ export_inference_graph.py”,第162行,文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages /tensorflow/python/platform/app.py”,第40行,运行_run(main = main,argv = argv,flags_parser = _parse_flags_tolerate_undef)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/运行_run_main(main,args)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/absl/app.py”中的第299行,位于“ site-packages / absl / app.py”行中,在_run_main sys.exit(main(argv))文件“ export_inference_graph.py”中的第250行,在主write_inference_graph = FLAGS.write_inference_graph中的第158行中)文件“ / home / user / anaconda3 / envs / my_env / lib / python3 .6 / site-packages / object_detection / exporter.py”,第497行,在export_inference_graph中,write_inference_graph = write_inference_graph中)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/object_detection/exporter.py”中的行426,在_export_inference_graph training_checkpoint_prefix = checkpoint_to_use)文件“ / home / user / anaconda3 / envs / my_env / lib / python3.6 / site-packages / object_detection / exporter.py“,在write_graph_and_checkpoint tf.import_graph_def(inference_graph_def,name =”'')中的第331行,文件“ / home / user / anaconda3 / envs / my_env / lib / python3.6 / site-packages / tensorflow / python / util / deprecation.py“,第507行,在new_func中返回func(* args,** kwargs)文件” / home / user / anaconda3 / envs /my_env/lib/python3.6/site-packages/tensorflow/python/framework/importer.py“,第443行,在import_graph_def _ProcessNewOps(graph)文件中/home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/importer.py”,第236行,在_ProcessNewOps中,用于graph._add_new_tf_operations(compute_devices = False):# pylint:disable =受保护的访问文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”,行3751,在_add_new_tf_operations中用于c_api_util中的c_op .new_tf_operations(self)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”,行3751,用于c_api_util.new_tf_operations中的c_op( self)文件“ /home/user/anaconda3/envs/my_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”,行3641,位于_create_op_from_tf_operation ret = Operation(c_op,self)文件中“ / home / user / anaconda3 / envs / my_env / lib / python3。6 / site-packages / tensorflow / python / framework / ops.py“,第2005行,在初始化self._traceback = tf_stack.extract_stack()

实际上,它一直在正确地工作,无法弄清楚现在发生了什么。我也尝试了快速的rcnn(它已经开始工作了),但是它也开始失败了。

这是配置文件。我目前正在为2个班级做它

# 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
}

找到一个2中github.But没有用的,类似的错误了。任何帮助将不胜感激。如果您需要更多信息,请发表评论。谢谢!

Carobnodrvo

您确定您的模型training/model.ckpt-10250faster_rcnn_inception_v2_pets模型吗?该错误NotFoundError: Key Conv/biases not found in checkpoint [[{{node save/RestoreV2}}]]表明它无法Conv/biases从检查点恢复

另外,请确保您使用的是对象检测框架支持的TF版本。您可以在此处找到所有发行版

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Tensorflow对象检测API中顺序导出两个不同的推理图时出错

对象检测:导出/导入推理时出错

导出推理图时出错(ValueError)

在 Tensorflow 中导出推理图时出现“解析输入...形状不完整”错误

修改并组合使用tensorflow对象检测API生成的两个不同的冻结图以进行推理

导出推理图后,ssd_mobilenet_v2_coco无法检测到自定义训练对象

在 JQgrid 中导出 pdf 时出错

在开发方法中导出IPA时出错

如何从pts标签文件中导出TFRecords用于Tensorflow对象检测API?

ios-在Xcode中导出存档文件时出错

在以Java编码的Eclipse中导出JAR文件时出错

在Python中导入LinkedIn API时出错

将Tensorflow冻结的推理图加载到OpenCV DNN时出错

实现 tensorflow 对象检测模型时出错

导出推理图和冻结图之间的区别?

TF 对象检测:返回推理负载的子集

在对象检测API中运行export_inference_graph.py时出错

使用fast_rcnn_inception_v2_pets模型运行tensorflow对象检测api时出错

安装对象检测API Ubuntu期间Protobuf库编译时出错

在未定义的 JavaScript 对象中导入类时出错

在无向图代码中检测循环时出错

使用 round 命令时出错以及如何在 NetLogo 6.2 中导出 .csv 表

在无GUI的pyqtgraph中导出图

如何从保存的模型中导出RT图

Maple:在隐藏循环中导出图

Tensorflow对象检测API-运行model_builder_test.py模块'tensorflow'没有属性'contrib'时出错

Tensorflow对象检测API中的图验证损失

使用 OpenCV 的对象检测 API 但颜色输出错误

在 R 中导出模型汇总表时找不到对象