当前位置: 首页>>代码示例>>Python>>正文


Python losses_builder.build方法代码示例

本文整理汇总了Python中object_detection.builders.losses_builder.build方法的典型用法代码示例。如果您正苦于以下问题:Python losses_builder.build方法的具体用法?Python losses_builder.build怎么用?Python losses_builder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在object_detection.builders.losses_builder的用法示例。


在下文中一共展示了losses_builder.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [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

示例2: test_build_weighted_l2_localization_loss

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_weighted_l2_localization_loss(self):
    losses_text_proto = """
      localization_loss {
        weighted_l2 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedL2LocalizationLoss)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:losses_builder_test.py

示例3: test_build_weighted_smooth_l1_localization_loss

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_weighted_smooth_l1_localization_loss(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:losses_builder_test.py

示例4: test_anchorwise_output

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_anchorwise_output(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
          anchorwise_output: true
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss))
    predictions = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]])
    targets = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]])
    weights = tf.constant([[1.0, 1.0]])
    loss = localization_loss(predictions, targets, weights=weights)
    self.assertEqual(loss.shape, [1, 2]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:24,代码来源:losses_builder_test.py

示例5: test_build_weighted_sigmoid_classification_loss

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_weighted_sigmoid_classification_loss(self):
    losses_text_proto = """
      classification_loss {
        weighted_sigmoid {
        }
      }
      localization_loss {
        weighted_l2 {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    classification_loss, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(classification_loss,
                               losses.WeightedSigmoidClassificationLoss)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:losses_builder_test.py

示例6: test_build_weighted_softmax_classification_loss

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_weighted_softmax_classification_loss(self):
    losses_text_proto = """
      classification_loss {
        weighted_softmax {
        }
      }
      localization_loss {
        weighted_l2 {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    classification_loss, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(classification_loss,
                               losses.WeightedSoftmaxClassificationLoss)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:losses_builder_test.py

示例7: test_build_bootstrapped_sigmoid_classification_loss

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_bootstrapped_sigmoid_classification_loss(self):
    losses_text_proto = """
      classification_loss {
        bootstrapped_sigmoid {
          alpha: 0.5
        }
      }
      localization_loss {
        weighted_l2 {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    classification_loss, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(classification_loss,
                               losses.BootstrappedSigmoidClassificationLoss)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:losses_builder_test.py

示例8: test_build_hard_example_miner_for_classification_loss

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_hard_example_miner_for_classification_loss(self):
    losses_text_proto = """
      localization_loss {
        weighted_l2 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
      hard_example_miner {
        loss_type: CLASSIFICATION
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, _, _, _, hard_example_miner = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(hard_example_miner, losses.HardExampleMiner))
    self.assertEqual(hard_example_miner._loss_type, 'cls') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:losses_builder_test.py

示例9: test_build_hard_example_miner_for_localization_loss

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_hard_example_miner_for_localization_loss(self):
    losses_text_proto = """
      localization_loss {
        weighted_l2 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
      hard_example_miner {
        loss_type: LOCALIZATION
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, _, _, _, hard_example_miner = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(hard_example_miner, losses.HardExampleMiner))
    self.assertEqual(hard_example_miner._loss_type, 'loc') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:losses_builder_test.py

示例10: build

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [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

示例11: test_build_weighted_l2_localization_loss

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_weighted_l2_localization_loss(self):
    losses_text_proto = """
      localization_loss {
        weighted_l2 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedL2LocalizationLoss)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:18,代码来源:losses_builder_test.py

示例12: test_build_weighted_smooth_l1_localization_loss_default_delta

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_weighted_smooth_l1_localization_loss_default_delta(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss))
    self.assertAlmostEqual(localization_loss._delta, 1.0) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:19,代码来源:losses_builder_test.py

示例13: test_build_weighted_smooth_l1_localization_loss_non_default_delta

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_weighted_smooth_l1_localization_loss_non_default_delta(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
          delta: 0.1
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss))
    self.assertAlmostEqual(localization_loss._delta, 0.1) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:20,代码来源:losses_builder_test.py

示例14: test_build_weighted_iou_localization_loss

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_weighted_iou_localization_loss(self):
    losses_text_proto = """
      localization_loss {
        weighted_iou {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedIOULocalizationLoss)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:18,代码来源:losses_builder_test.py

示例15: test_build_weighted_sigmoid_classification_loss

# 需要导入模块: from object_detection.builders import losses_builder [as 别名]
# 或者: from object_detection.builders.losses_builder import build [as 别名]
def test_build_weighted_sigmoid_classification_loss(self):
    losses_text_proto = """
      classification_loss {
        weighted_sigmoid {
        }
      }
      localization_loss {
        weighted_l2 {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    classification_loss, _, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(classification_loss,
                               losses.WeightedSigmoidClassificationLoss)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:18,代码来源:losses_builder_test.py


注:本文中的object_detection.builders.losses_builder.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。