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


Python model_pb2.DetectionModel方法代碼示例

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


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

示例1: get_configs_from_pipeline_file

# 需要導入模塊: from object_detection.protos import model_pb2 [as 別名]
# 或者: from object_detection.protos.model_pb2 import DetectionModel [as 別名]
def get_configs_from_pipeline_file():
  """Reads evaluation configuration from a pipeline_pb2.TrainEvalPipelineConfig.

  Reads evaluation config from file specified by pipeline_config_path flag.

  Returns:
    model_config: a model_pb2.DetectionModel
    eval_config: a eval_pb2.EvalConfig
    input_config: a input_reader_pb2.InputReader
  """
  pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
  with tf.gfile.GFile(FLAGS.pipeline_config_path, 'r') as f:
    text_format.Merge(f.read(), pipeline_config)

  model_config = pipeline_config.model
  if FLAGS.eval_training_data:
    eval_config = pipeline_config.train_config
  else:
    eval_config = pipeline_config.eval_config
  input_config = pipeline_config.eval_input_reader

  return model_config, eval_config, input_config 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:24,代碼來源:eval.py

示例2: build

# 需要導入模塊: from object_detection.protos import model_pb2 [as 別名]
# 或者: from object_detection.protos.model_pb2 import DetectionModel [as 別名]
def build(model_config, is_training):
  """Builds a DetectionModel based on the model config.

  Args:
    model_config: A model.proto object containing the config for the desired
      DetectionModel.
    is_training: True if this model is being built for training purposes.

  Returns:
    DetectionModel based on the config.

  Raises:
    ValueError: On invalid meta architecture or model.
  """
  if not isinstance(model_config, model_pb2.DetectionModel):
    raise ValueError('model_config not of type model_pb2.DetectionModel.')
  meta_architecture = model_config.WhichOneof('model')
  if meta_architecture == 'ssd':
    return _build_ssd_model(model_config.ssd, is_training)
  if meta_architecture == 'faster_rcnn':
    return _build_faster_rcnn_model(model_config.faster_rcnn, is_training)
  raise ValueError('Unknown meta architecture: {}'.format(meta_architecture)) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:24,代碼來源:model_builder.py

示例3: get_image_resizer_config

# 需要導入模塊: from object_detection.protos import model_pb2 [as 別名]
# 或者: from object_detection.protos.model_pb2 import DetectionModel [as 別名]
def get_image_resizer_config(model_config):
  """Returns the image resizer config from a model config.

  Args:
    model_config: A model_pb2.DetectionModel.

  Returns:
    An image_resizer_pb2.ImageResizer.

  Raises:
    ValueError: If the model type is not recognized.
  """
  meta_architecture = model_config.WhichOneof("model")
  if meta_architecture == "faster_rcnn":
    return model_config.faster_rcnn.image_resizer
  if meta_architecture == "ssd":
    return model_config.ssd.image_resizer

  raise ValueError("Unknown model type: {}".format(meta_architecture)) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:21,代碼來源:config_util.py

示例4: build

# 需要導入模塊: from object_detection.protos import model_pb2 [as 別名]
# 或者: from object_detection.protos.model_pb2 import DetectionModel [as 別名]
def build(model_config, is_training, add_summaries=True):
  """Builds a DetectionModel based on the model config.

  Args:
    model_config: A model.proto object containing the config for the desired
      DetectionModel.
    is_training: True if this model is being built for training purposes.
    add_summaries: Whether to add tensorflow summaries in the model graph.
  Returns:
    DetectionModel based on the config.

  Raises:
    ValueError: On invalid meta architecture or model.
  """
  if not isinstance(model_config, model_pb2.DetectionModel):
    raise ValueError('model_config not of type model_pb2.DetectionModel.')
  meta_architecture = model_config.WhichOneof('model')
  if meta_architecture == 'ssd':
    return _build_ssd_model(model_config.ssd, is_training, add_summaries)
  if meta_architecture == 'faster_rcnn':
    return _build_faster_rcnn_model(model_config.faster_rcnn, is_training,
                                    add_summaries)
  raise ValueError('Unknown meta architecture: {}'.format(meta_architecture)) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:25,代碼來源:model_builder.py

示例5: build

# 需要導入模塊: from object_detection.protos import model_pb2 [as 別名]
# 或者: from object_detection.protos.model_pb2 import DetectionModel [as 別名]
def build(model_config, is_training, add_summaries=True):
  """Builds a DetectionModel based on the model config.

  Args:
    model_config: A model.proto object containing the config for the desired
      DetectionModel.
    is_training: True if this model is being built for training purposes.
    add_summaries: Whether to add tensorflow summaries in the model graph.

  Returns:
    DetectionModel based on the config.

  Raises:
    ValueError: On invalid meta architecture or model.
  """
  if not isinstance(model_config, model_pb2.DetectionModel):
    raise ValueError('model_config not of type model_pb2.DetectionModel.')
  meta_architecture = model_config.WhichOneof('model')
  if meta_architecture == 'ssd':
    return _build_ssd_model(model_config.ssd, is_training, add_summaries)
  if meta_architecture == 'faster_rcnn':
    return _build_faster_rcnn_model(model_config.faster_rcnn, is_training,
                                    add_summaries)
  raise ValueError('Unknown meta architecture: {}'.format(meta_architecture)) 
開發者ID:cagbal,項目名稱:ros_people_object_detection_tensorflow,代碼行數:26,代碼來源:model_builder.py

示例6: get_number_of_classes

# 需要導入模塊: from object_detection.protos import model_pb2 [as 別名]
# 或者: from object_detection.protos.model_pb2 import DetectionModel [as 別名]
def get_number_of_classes(model_config):
  """Returns the number of classes for a detection model.

  Args:
    model_config: A model_pb2.DetectionModel.

  Returns:
    Number of classes.

  Raises:
    ValueError: If the model type is not recognized.
  """
  meta_architecture = model_config.WhichOneof("model")
  if meta_architecture == "faster_rcnn":
    return model_config.faster_rcnn.num_classes
  if meta_architecture == "ssd":
    return model_config.ssd.num_classes

  raise ValueError("Expected the model to be one of 'faster_rcnn' or 'ssd'.") 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:21,代碼來源:config_util.py

示例7: get_configs_from_multiple_files

# 需要導入模塊: from object_detection.protos import model_pb2 [as 別名]
# 或者: from object_detection.protos.model_pb2 import DetectionModel [as 別名]
def get_configs_from_multiple_files():
  """Reads evaluation configuration from multiple config files.

  Reads the evaluation config from the following files:
    model_config: Read from --model_config_path
    eval_config: Read from --eval_config_path
    input_config: Read from --input_config_path

  Returns:
    model_config: a model_pb2.DetectionModel
    eval_config: a eval_pb2.EvalConfig
    input_config: a input_reader_pb2.InputReader
  """
  eval_config = eval_pb2.EvalConfig()
  with tf.gfile.GFile(FLAGS.eval_config_path, 'r') as f:
    text_format.Merge(f.read(), eval_config)

  model_config = model_pb2.DetectionModel()
  with tf.gfile.GFile(FLAGS.model_config_path, 'r') as f:
    text_format.Merge(f.read(), model_config)

  input_config = input_reader_pb2.InputReader()
  with tf.gfile.GFile(FLAGS.input_config_path, 'r') as f:
    text_format.Merge(f.read(), input_config)

  return model_config, eval_config, input_config 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:28,代碼來源:eval.py

示例8: create_model

# 需要導入模塊: from object_detection.protos import model_pb2 [as 別名]
# 或者: from object_detection.protos.model_pb2 import DetectionModel [as 別名]
def create_model(self, model_config):
    """Builds a DetectionModel based on the model config.

    Args:
      model_config: A model.proto object containing the config for the desired
        DetectionModel.

    Returns:
      DetectionModel based on the config.
    """
    return model_builder.build(model_config, is_training=True) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:13,代碼來源:model_builder_test.py

示例9: get_configs_from_multiple_files

# 需要導入模塊: from object_detection.protos import model_pb2 [as 別名]
# 或者: from object_detection.protos.model_pb2 import DetectionModel [as 別名]
def get_configs_from_multiple_files():
  """Reads training configuration from multiple config files.

  Reads the training config from the following files:
    model_config: Read from --model_config_path
    train_config: Read from --train_config_path
    input_config: Read from --input_config_path

  Returns:
    model_config: model_pb2.DetectionModel
    train_config: train_pb2.TrainConfig
    input_config: input_reader_pb2.InputReader
  """
  train_config = train_pb2.TrainConfig()
  with tf.gfile.GFile(FLAGS.train_config_path, 'r') as f:
    text_format.Merge(f.read(), train_config)

  model_config = model_pb2.DetectionModel()
  with tf.gfile.GFile(FLAGS.model_config_path, 'r') as f:
    text_format.Merge(f.read(), model_config)

  input_config = input_reader_pb2.InputReader()
  with tf.gfile.GFile(FLAGS.input_config_path, 'r') as f:
    text_format.Merge(f.read(), input_config)

  return model_config, train_config, input_config 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:28,代碼來源:train.py

示例10: testGetImageResizerConfig

# 需要導入模塊: from object_detection.protos import model_pb2 [as 別名]
# 或者: from object_detection.protos.model_pb2 import DetectionModel [as 別名]
def  testGetImageResizerConfig(self):
    """Tests that number of classes can be retrieved."""
    model_config = model_pb2.DetectionModel()
    model_config.faster_rcnn.image_resizer.fixed_shape_resizer.height = 100
    model_config.faster_rcnn.image_resizer.fixed_shape_resizer.width = 300
    image_resizer_config = config_util.get_image_resizer_config(model_config)
    self.assertEqual(image_resizer_config.fixed_shape_resizer.height, 100)
    self.assertEqual(image_resizer_config.fixed_shape_resizer.width, 300) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:10,代碼來源:config_util_test.py


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