當前位置: 首頁>>代碼示例>>Python>>正文


Python config_util.save_pipeline_config方法代碼示例

本文整理匯總了Python中object_detection.utils.config_util.save_pipeline_config方法的典型用法代碼示例。如果您正苦於以下問題:Python config_util.save_pipeline_config方法的具體用法?Python config_util.save_pipeline_config怎麽用?Python config_util.save_pipeline_config使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在object_detection.utils.config_util的用法示例。


在下文中一共展示了config_util.save_pipeline_config方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_save_pipeline_config

# 需要導入模塊: from object_detection.utils import config_util [as 別名]
# 或者: from object_detection.utils.config_util import save_pipeline_config [as 別名]
def test_save_pipeline_config(self):
    """Tests that the pipeline config is properly saved to disk."""
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.model.faster_rcnn.num_classes = 10
    pipeline_config.train_config.batch_size = 32
    pipeline_config.train_input_reader.label_map_path = "path/to/label_map"
    pipeline_config.eval_config.num_examples = 20
    pipeline_config.eval_input_reader.add().queue_capacity = 100

    config_util.save_pipeline_config(pipeline_config, self.get_temp_dir())
    configs = config_util.get_configs_from_pipeline_file(
        os.path.join(self.get_temp_dir(), "pipeline.config"))
    pipeline_config_reconstructed = (
        config_util.create_pipeline_proto_from_configs(configs))

    self.assertEqual(pipeline_config, pipeline_config_reconstructed) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:18,代碼來源:config_util_test.py

示例2: test_save_pipeline_config

# 需要導入模塊: from object_detection.utils import config_util [as 別名]
# 或者: from object_detection.utils.config_util import save_pipeline_config [as 別名]
def test_save_pipeline_config(self):
    """Tests that the pipeline config is properly saved to disk."""
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.model.faster_rcnn.num_classes = 10
    pipeline_config.train_config.batch_size = 32
    pipeline_config.train_input_reader.label_map_path = "path/to/label_map"
    pipeline_config.eval_config.num_examples = 20
    pipeline_config.eval_input_reader.queue_capacity = 100

    config_util.save_pipeline_config(pipeline_config, self.get_temp_dir())
    configs = config_util.get_configs_from_pipeline_file(
        os.path.join(self.get_temp_dir(), "pipeline.config"))
    pipeline_config_reconstructed = (
        config_util.create_pipeline_proto_from_configs(configs))

    self.assertEqual(pipeline_config, pipeline_config_reconstructed) 
開發者ID:ambakick,項目名稱:Person-Detection-and-Tracking,代碼行數:18,代碼來源:config_util_test.py

示例3: create_config_file

# 需要導入模塊: from object_detection.utils import config_util [as 別名]
# 或者: from object_detection.utils.config_util import save_pipeline_config [as 別名]
def create_config_file(input_path, config_params, network_type):
    configs = config_util.get_configs_from_pipeline_file(input_path)

    if config_params['checkpoint_path'] is not None:
        prefix = ""
        for ckpt_file in os.listdir(os.path.join('/checkpoints/'+ network_type, config_params['checkpoint_path'])):
            if ckpt_file.endswith(".index"):
                prefix = ckpt_file.split(".index")[0]
                config_params['checkpoint_path'] = '/checkpoints/'+network_type+'/'+config_params['checkpoint_path']+'/'+prefix


    else:
        config_params['checkpoint_path'] = '/weights/'+network_type+'/model.ckpt'

    new_configs = None

    if network_type == "ssd_mobilenet" or network_type == "ssd_inception":
        new_configs = config_ssd_mobilenet_inception(configs, config_params)

    elif network_type == "ssd_resnet_50" or network_type == "ssd_fpn":
        new_configs = config_ssd_mobilenet_inception(configs, config_params)

    elif network_type == "frcnn_resnet_50" or network_type == "frcnn_resnet_101":
        new_configs = config_frcnn_resnet_50_101(configs, config_params)
        

    pipeline_config = config_util.create_pipeline_proto_from_configs(new_configs)
    
    config_util.save_pipeline_config(pipeline_config, '/training_dir/model') 
開發者ID:BMW-InnovationLab,項目名稱:BMW-TensorFlow-Training-GUI,代碼行數:31,代碼來源:create_config_file.py

示例4: export_inference_graph

# 需要導入模塊: from object_detection.utils import config_util [as 別名]
# 或者: from object_detection.utils.config_util import save_pipeline_config [as 別名]
def export_inference_graph(input_type,
                           pipeline_config,
                           trained_checkpoint_prefix,
                           output_directory,
                           input_shape=None,
                           output_collection_name='inference_op',
                           additional_output_tensor_names=None,
                           write_inference_graph=False):
  """Exports inference graph for the model specified in the pipeline config.

  Args:
    input_type: Type of input for the graph. Can be one of ['image_tensor',
      'encoded_image_string_tensor', 'tf_example'].
    pipeline_config: pipeline_pb2.TrainAndEvalPipelineConfig proto.
    trained_checkpoint_prefix: Path to the trained checkpoint file.
    output_directory: Path to write outputs.
    input_shape: Sets a fixed shape for an `image_tensor` input. If not
      specified, will default to [None, None, None, 3].
    output_collection_name: Name of collection to add output tensors to.
      If None, does not add output tensors to a collection.
    additional_output_tensor_names: list of additional output
      tensors to include in the frozen graph.
    write_inference_graph: If true, writes inference graph to disk.
  """
  detection_model = model_builder.build(pipeline_config.model,
                                        is_training=False)
  graph_rewriter_fn = None
  if pipeline_config.HasField('graph_rewriter'):
    graph_rewriter_config = pipeline_config.graph_rewriter
    graph_rewriter_fn = graph_rewriter_builder.build(graph_rewriter_config,
                                                     is_training=False)
  _export_inference_graph(
      input_type,
      detection_model,
      pipeline_config.eval_config.use_moving_averages,
      trained_checkpoint_prefix,
      output_directory,
      additional_output_tensor_names,
      input_shape,
      output_collection_name,
      graph_hook_fn=graph_rewriter_fn,
      write_inference_graph=write_inference_graph)
  pipeline_config.eval_config.use_moving_averages = False
  config_util.save_pipeline_config(pipeline_config, output_directory) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:46,代碼來源:exporter.py

示例5: export_inference_graph

# 需要導入模塊: from object_detection.utils import config_util [as 別名]
# 或者: from object_detection.utils.config_util import save_pipeline_config [as 別名]
def export_inference_graph(input_type,
                           pipeline_config,
                           trained_checkpoint_prefix,
                           output_directory,
                           input_shape=None,
                           output_collection_name='inference_op',
                           additional_output_tensor_names=None,
                           write_inference_graph=False,
                           use_side_inputs=False,
                           side_input_shapes=None,
                           side_input_names=None,
                           side_input_types=None):
  """Exports inference graph for the model specified in the pipeline config.

  Args:
    input_type: Type of input for the graph. Can be one of ['image_tensor',
      'encoded_image_string_tensor', 'tf_example'].
    pipeline_config: pipeline_pb2.TrainAndEvalPipelineConfig proto.
    trained_checkpoint_prefix: Path to the trained checkpoint file.
    output_directory: Path to write outputs.
    input_shape: Sets a fixed shape for an `image_tensor` input. If not
      specified, will default to [None, None, None, 3].
    output_collection_name: Name of collection to add output tensors to.
      If None, does not add output tensors to a collection.
    additional_output_tensor_names: list of additional output
      tensors to include in the frozen graph.
    write_inference_graph: If true, writes inference graph to disk.
    use_side_inputs: If True, the model requires side_inputs.
    side_input_shapes: List of shapes of the side input tensors,
      required if use_side_inputs is True.
    side_input_names: List of names of the side input tensors,
      required if use_side_inputs is True.
    side_input_types: List of types of the side input tensors,
      required if use_side_inputs is True.
  """
  detection_model = model_builder.build(pipeline_config.model,
                                        is_training=False)
  graph_rewriter_fn = None
  if pipeline_config.HasField('graph_rewriter'):
    graph_rewriter_config = pipeline_config.graph_rewriter
    graph_rewriter_fn = graph_rewriter_builder.build(graph_rewriter_config,
                                                     is_training=False)
  _export_inference_graph(
      input_type,
      detection_model,
      pipeline_config.eval_config.use_moving_averages,
      trained_checkpoint_prefix,
      output_directory,
      additional_output_tensor_names,
      input_shape,
      output_collection_name,
      graph_hook_fn=graph_rewriter_fn,
      write_inference_graph=write_inference_graph,
      use_side_inputs=use_side_inputs,
      side_input_shapes=side_input_shapes,
      side_input_names=side_input_names,
      side_input_types=side_input_types)
  pipeline_config.eval_config.use_moving_averages = False
  config_util.save_pipeline_config(pipeline_config, output_directory) 
開發者ID:tensorflow,項目名稱:models,代碼行數:61,代碼來源:exporter.py

示例6: export_inference_graph

# 需要導入模塊: from object_detection.utils import config_util [as 別名]
# 或者: from object_detection.utils.config_util import save_pipeline_config [as 別名]
def export_inference_graph(input_type,
                           pipeline_config,
                           trained_checkpoint_dir,
                           output_directory):
  """Exports inference graph for the model specified in the pipeline config.

  This function creates `output_directory` if it does not already exist,
  which will hold a copy of the pipeline config with filename `pipeline.config`,
  and two subdirectories named `checkpoint` and `saved_model`
  (containing the exported checkpoint and SavedModel respectively).

  Args:
    input_type: Type of input for the graph. Can be one of ['image_tensor',
      'encoded_image_string_tensor', 'tf_example'].
    pipeline_config: pipeline_pb2.TrainAndEvalPipelineConfig proto.
    trained_checkpoint_dir: Path to the trained checkpoint file.
    output_directory: Path to write outputs.
  Raises:
    ValueError: if input_type is invalid.
  """
  output_checkpoint_directory = os.path.join(output_directory, 'checkpoint')
  output_saved_model_directory = os.path.join(output_directory, 'saved_model')

  detection_model = model_builder.build(pipeline_config.model,
                                        is_training=False)

  ckpt = tf.train.Checkpoint(
      model=detection_model)
  manager = tf.train.CheckpointManager(
      ckpt, trained_checkpoint_dir, max_to_keep=1)
  status = ckpt.restore(manager.latest_checkpoint).expect_partial()

  if input_type not in DETECTION_MODULE_MAP:
    raise ValueError('Unrecognized `input_type`')
  detection_module = DETECTION_MODULE_MAP[input_type](detection_model)
  # Getting the concrete function traces the graph and forces variables to
  # be constructed --- only after this can we save the checkpoint and
  # saved model.
  concrete_function = detection_module.__call__.get_concrete_function()
  status.assert_existing_objects_matched()

  exported_checkpoint_manager = tf.train.CheckpointManager(
      ckpt, output_checkpoint_directory, max_to_keep=1)
  exported_checkpoint_manager.save(checkpoint_number=0)

  tf.saved_model.save(detection_module,
                      output_saved_model_directory,
                      signatures=concrete_function)

  config_util.save_pipeline_config(pipeline_config, output_directory) 
開發者ID:tensorflow,項目名稱:models,代碼行數:52,代碼來源:exporter_lib_v2.py


注:本文中的object_detection.utils.config_util.save_pipeline_config方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。