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


Python ssd_meta_arch.SSDMetaArch方法代码示例

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


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

示例1: _create_model

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def _create_model(self,
                    apply_hard_mining=True,
                    normalize_loc_loss_by_codesize=False,
                    add_background_class=True,
                    random_example_sampling=False,
                    weight_regression_loss_by_score=False,
                    use_expected_classification_loss_under_sampling=False,
                    min_num_negative_samples=1,
                    desired_negative_sampling_ratio=3,
                    use_keras=False,
                    predict_mask=False,
                    use_static_shapes=False,
                    nms_max_size_per_class=5):
    return super(SsdMetaArchTest, self)._create_model(
        model_fn=ssd_meta_arch.SSDMetaArch,
        apply_hard_mining=apply_hard_mining,
        normalize_loc_loss_by_codesize=normalize_loc_loss_by_codesize,
        add_background_class=add_background_class,
        random_example_sampling=random_example_sampling,
        weight_regression_loss_by_score=weight_regression_loss_by_score,
        use_expected_classification_loss_under_sampling=
        use_expected_classification_loss_under_sampling,
        min_num_negative_samples=min_num_negative_samples,
        desired_negative_sampling_ratio=desired_negative_sampling_ratio,
        use_keras=use_keras,
        predict_mask=predict_mask,
        use_static_shapes=use_static_shapes,
        nms_max_size_per_class=nms_max_size_per_class) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:30,代码来源:ssd_meta_arch_test.py

示例2: test_create_ssd_models_from_config

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def test_create_ssd_models_from_config(self):
    model_proto = self.create_default_ssd_model_proto()
    ssd_feature_extractor_map = {}
    ssd_feature_extractor_map.update(
        model_builder.SSD_FEATURE_EXTRACTOR_CLASS_MAP)
    ssd_feature_extractor_map.update(
        model_builder.SSD_KERAS_FEATURE_EXTRACTOR_CLASS_MAP)

    for extractor_type, extractor_class in ssd_feature_extractor_map.items():
      model_proto.ssd.feature_extractor.type = extractor_type
      model = model_builder.build(model_proto, is_training=True)
      self.assertIsInstance(model, ssd_meta_arch.SSDMetaArch)
      self.assertIsInstance(model._feature_extractor, extractor_class) 
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:15,代码来源:model_builder_test.py

示例3: _create_model

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def _create_model(
      self,
      apply_hard_mining=True,
      normalize_loc_loss_by_codesize=False,
      add_background_class=True,
      random_example_sampling=False,
      expected_loss_weights=model_pb2.DetectionModel().ssd.loss.NONE,
      min_num_negative_samples=1,
      desired_negative_sampling_ratio=3,
      use_keras=False,
      predict_mask=False,
      use_static_shapes=False,
      nms_max_size_per_class=5):
    return super(SsdMetaArchTest, self)._create_model(
        model_fn=ssd_meta_arch.SSDMetaArch,
        apply_hard_mining=apply_hard_mining,
        normalize_loc_loss_by_codesize=normalize_loc_loss_by_codesize,
        add_background_class=add_background_class,
        random_example_sampling=random_example_sampling,
        expected_loss_weights=expected_loss_weights,
        min_num_negative_samples=min_num_negative_samples,
        desired_negative_sampling_ratio=desired_negative_sampling_ratio,
        use_keras=use_keras,
        predict_mask=predict_mask,
        use_static_shapes=use_static_shapes,
        nms_max_size_per_class=nms_max_size_per_class) 
开发者ID:IBM,项目名称:MAX-Object-Detector,代码行数:28,代码来源:ssd_meta_arch_test.py

示例4: _create_model

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def _create_model(
      self,
      apply_hard_mining=True,
      normalize_loc_loss_by_codesize=False,
      add_background_class=True,
      random_example_sampling=False,
      expected_loss_weights=model_pb2.DetectionModel().ssd.loss.NONE,
      min_num_negative_samples=1,
      desired_negative_sampling_ratio=3,
      predict_mask=False,
      use_static_shapes=False,
      nms_max_size_per_class=5,
      calibration_mapping_value=None,
      return_raw_detections_during_predict=False):
    return super(SsdMetaArchTest, self)._create_model(
        model_fn=ssd_meta_arch.SSDMetaArch,
        apply_hard_mining=apply_hard_mining,
        normalize_loc_loss_by_codesize=normalize_loc_loss_by_codesize,
        add_background_class=add_background_class,
        random_example_sampling=random_example_sampling,
        expected_loss_weights=expected_loss_weights,
        min_num_negative_samples=min_num_negative_samples,
        desired_negative_sampling_ratio=desired_negative_sampling_ratio,
        predict_mask=predict_mask,
        use_static_shapes=use_static_shapes,
        nms_max_size_per_class=nms_max_size_per_class,
        calibration_mapping_value=calibration_mapping_value,
        return_raw_detections_during_predict=(
            return_raw_detections_during_predict)) 
开发者ID:tensorflow,项目名称:models,代码行数:31,代码来源:ssd_meta_arch_test.py

示例5: test_create_ssd_models_from_config

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def test_create_ssd_models_from_config(self):
    model_proto = self.create_default_ssd_model_proto()
    for extractor_type, extractor_class in self.ssd_feature_extractors().items(
    ):
      model_proto.ssd.feature_extractor.type = extractor_type
      model = model_builder.build(model_proto, is_training=True)
      self.assertIsInstance(model, ssd_meta_arch.SSDMetaArch)
      self.assertIsInstance(model._feature_extractor, extractor_class) 
开发者ID:tensorflow,项目名称:models,代码行数:10,代码来源:model_builder_test.py

示例6: setUp

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def setUp(self):
    """Set up mock SSD model.

    Here we set up a simple mock SSD model that will always predict 4
    detections that happen to always be exactly the anchors that are set up
    in the above MockAnchorGenerator.  Because we let max_detections=5,
    we will also always end up with an extra padded row in the detection
    results.
    """
    is_training = False
    self._num_classes = 1
    mock_anchor_generator = MockAnchorGenerator2x2()
    mock_box_predictor = test_utils.MockBoxPredictor(
        is_training, self._num_classes)
    mock_box_coder = test_utils.MockBoxCoder()
    fake_feature_extractor = FakeSSDFeatureExtractor()
    mock_matcher = test_utils.MockMatcher()
    region_similarity_calculator = sim_calc.IouSimilarity()

    def image_resizer_fn(image):
      return tf.identity(image)

    classification_loss = losses.WeightedSigmoidClassificationLoss(
        anchorwise_output=True)
    localization_loss = losses.WeightedSmoothL1LocalizationLoss(
        anchorwise_output=True)
    non_max_suppression_fn = functools.partial(
        post_processing.batch_multiclass_non_max_suppression,
        score_thresh=-20.0,
        iou_thresh=1.0,
        max_size_per_class=5,
        max_total_size=5)
    classification_loss_weight = 1.0
    localization_loss_weight = 1.0
    normalize_loss_by_num_matches = False

    # This hard example miner is expected to be a no-op.
    hard_example_miner = losses.HardExampleMiner(
        num_hard_examples=None,
        iou_threshold=1.0)

    self._num_anchors = 4
    self._code_size = 4
    self._model = ssd_meta_arch.SSDMetaArch(
        is_training, mock_anchor_generator, mock_box_predictor, mock_box_coder,
        fake_feature_extractor, mock_matcher, region_similarity_calculator,
        image_resizer_fn, non_max_suppression_fn, tf.identity,
        classification_loss, localization_loss, classification_loss_weight,
        localization_loss_weight, normalize_loss_by_num_matches,
        hard_example_miner) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:52,代码来源:ssd_meta_arch_test.py

示例7: _build_ssd_model

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def _build_ssd_model(ssd_config, is_training):
  """Builds an SSD detection model based on the model config.

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

  Returns:
    SSDMetaArch based on the config.
  Raises:
    ValueError: If ssd_config.type is not recognized (i.e. not registered in
      model_class_map).
  """
  num_classes = ssd_config.num_classes

  # Feature extractor
  feature_extractor = _build_ssd_feature_extractor(ssd_config.feature_extractor,
                                                   is_training)

  box_coder = box_coder_builder.build(ssd_config.box_coder)
  matcher = matcher_builder.build(ssd_config.matcher)
  region_similarity_calculator = sim_calc.build(
      ssd_config.similarity_calculator)
  ssd_box_predictor = box_predictor_builder.build(hyperparams_builder.build,
                                                  ssd_config.box_predictor,
                                                  is_training, num_classes)
  anchor_generator = anchor_generator_builder.build(
      ssd_config.anchor_generator)
  image_resizer_fn = image_resizer_builder.build(ssd_config.image_resizer)
  non_max_suppression_fn, score_conversion_fn = post_processing_builder.build(
      ssd_config.post_processing)
  (classification_loss, localization_loss, classification_weight,
   localization_weight,
   hard_example_miner) = losses_builder.build(ssd_config.loss)
  normalize_loss_by_num_matches = ssd_config.normalize_loss_by_num_matches

  return ssd_meta_arch.SSDMetaArch(
      is_training,
      anchor_generator,
      ssd_box_predictor,
      box_coder,
      feature_extractor,
      matcher,
      region_similarity_calculator,
      image_resizer_fn,
      non_max_suppression_fn,
      score_conversion_fn,
      classification_loss,
      localization_loss,
      classification_weight,
      localization_weight,
      normalize_loss_by_num_matches,
      hard_example_miner) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:56,代码来源:model_builder.py

示例8: _create_model

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def _create_model(self, apply_hard_mining=True,
                    normalize_loc_loss_by_codesize=False):
    is_training = False
    num_classes = 1
    mock_anchor_generator = MockAnchorGenerator2x2()
    mock_box_predictor = test_utils.MockBoxPredictor(
        is_training, num_classes)
    mock_box_coder = test_utils.MockBoxCoder()
    fake_feature_extractor = FakeSSDFeatureExtractor()
    mock_matcher = test_utils.MockMatcher()
    region_similarity_calculator = sim_calc.IouSimilarity()
    encode_background_as_zeros = False
    def image_resizer_fn(image):
      return [tf.identity(image), tf.shape(image)]

    classification_loss = losses.WeightedSigmoidClassificationLoss()
    localization_loss = losses.WeightedSmoothL1LocalizationLoss()
    non_max_suppression_fn = functools.partial(
        post_processing.batch_multiclass_non_max_suppression,
        score_thresh=-20.0,
        iou_thresh=1.0,
        max_size_per_class=5,
        max_total_size=5)
    classification_loss_weight = 1.0
    localization_loss_weight = 1.0
    negative_class_weight = 1.0
    normalize_loss_by_num_matches = False

    hard_example_miner = None
    if apply_hard_mining:
      # This hard example miner is expected to be a no-op.
      hard_example_miner = losses.HardExampleMiner(
          num_hard_examples=None,
          iou_threshold=1.0)

    code_size = 4
    model = ssd_meta_arch.SSDMetaArch(
        is_training, mock_anchor_generator, mock_box_predictor, mock_box_coder,
        fake_feature_extractor, mock_matcher, region_similarity_calculator,
        encode_background_as_zeros, negative_class_weight, image_resizer_fn,
        non_max_suppression_fn, tf.identity, classification_loss,
        localization_loss, classification_loss_weight, localization_loss_weight,
        normalize_loss_by_num_matches, hard_example_miner, add_summaries=False,
        normalize_loc_loss_by_codesize=normalize_loc_loss_by_codesize)
    return model, num_classes, mock_anchor_generator.num_anchors(), code_size 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:47,代码来源:ssd_meta_arch_test.py

示例9: _build_ssd_model

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def _build_ssd_model(ssd_config, is_training):
  """Builds an SSD detection model based on the model config.

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

  Returns:
    SSDMetaArch based on the config.
  Raises:
    ValueError: If ssd_config.type is not recognized (i.e. not registered in
      model_class_map).
  """
  num_classes = ssd_config.num_classes

  # Feature extractor
  feature_extractor = _build_ssd_feature_extractor(ssd_config.feature_extractor,
                                                   is_training)

  box_coder = box_coder_builder.build(ssd_config.box_coder)
  matcher = matcher_builder.build(ssd_config.matcher)
  region_similarity_calculator = sim_calc.build(
      ssd_config.similarity_calculator)
  ssd_box_predictor = box_predictor_builder.build(hyperparams_builder.build,
                                                  ssd_config.box_predictor,
                                                  is_training, num_classes)
  anchor_generator = anchor_generator_builder.build(
      ssd_config.anchor_generator)
  image_resizer_fn = image_resizer_builder.build(ssd_config.image_resizer)
  non_max_suppression_fn, score_conversion_fn = post_processing_builder.build(
      ssd_config.post_processing)
  (classification_loss, localization_loss, classification_weight,
   localization_weight,
   hard_example_miner) = losses_builder.build(ssd_config.loss)
  normalize_loss_by_num_matches = ssd_config.normalize_loss_by_num_matches

  common_kwargs = {
      'is_training':is_training,
      'anchor_generator':anchor_generator,
      'box_predictor':ssd_box_predictor,
      'box_coder':box_coder,
      'feature_extractor':feature_extractor,
      'matcher':matcher,
      'region_similarity_calculator':region_similarity_calculator,
      'image_resizer_fn':image_resizer_fn,
      'non_max_suppression_fn':non_max_suppression_fn,
      'score_conversion_fn':score_conversion_fn,
      'classification_loss':classification_loss,
      'localization_loss':localization_loss,
      'classification_loss_weight':classification_weight,
      'localization_loss_weight':localization_weight,
      'normalize_loss_by_num_matches':normalize_loss_by_num_matches,
      'hard_example_miner':hard_example_miner}

  if isinstance(anchor_generator, yolo_grid_anchor_generator.YoloGridAnchorGenerator):
    return yolo_meta_arch.YOLOMetaArch(**common_kwargs)
  else:
    return ssd_meta_arch.SSDMetaArch(**common_kwargs) 
开发者ID:rky0930,项目名称:yolo_v2,代码行数:61,代码来源:model_builder.py

示例10: _create_model

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def _create_model(self, apply_hard_mining=True):
    is_training = False
    num_classes = 1
    mock_anchor_generator = MockAnchorGenerator2x2()
    mock_box_predictor = test_utils.MockBoxPredictor(
        is_training, num_classes)
    mock_box_coder = test_utils.MockBoxCoder()
    fake_feature_extractor = FakeSSDFeatureExtractor()
    mock_matcher = test_utils.MockMatcher()
    region_similarity_calculator = sim_calc.IouSimilarity()

    def image_resizer_fn(image):
      return [tf.identity(image), tf.shape(image)]

    classification_loss = losses.WeightedSigmoidClassificationLoss()
    localization_loss = losses.WeightedSmoothL1LocalizationLoss()
    non_max_suppression_fn = functools.partial(
        post_processing.batch_multiclass_non_max_suppression,
        score_thresh=-20.0,
        iou_thresh=1.0,
        max_size_per_class=5,
        max_total_size=5)
    classification_loss_weight = 1.0
    localization_loss_weight = 1.0
    normalize_loss_by_num_matches = False

    hard_example_miner = None
    if apply_hard_mining:
      # This hard example miner is expected to be a no-op.
      hard_example_miner = losses.HardExampleMiner(
          num_hard_examples=None,
          iou_threshold=1.0)

    code_size = 4
    model = ssd_meta_arch.SSDMetaArch(
        is_training, mock_anchor_generator, mock_box_predictor, mock_box_coder,
        fake_feature_extractor, mock_matcher, region_similarity_calculator,
        image_resizer_fn, non_max_suppression_fn, tf.identity,
        classification_loss, localization_loss, classification_loss_weight,
        localization_loss_weight, normalize_loss_by_num_matches,
        hard_example_miner, add_summaries=False)
    return model, num_classes, mock_anchor_generator.num_anchors(), code_size 
开发者ID:ShreyAmbesh,项目名称:Traffic-Rule-Violation-Detection-System,代码行数:44,代码来源:ssd_meta_arch_test.py

示例11: _build_ssd_model

# 需要导入模块: from object_detection.meta_architectures import ssd_meta_arch [as 别名]
# 或者: from object_detection.meta_architectures.ssd_meta_arch import SSDMetaArch [as 别名]
def _build_ssd_model(ssd_config, is_training, add_summaries):
  """Builds an SSD detection model based on the model config.

  Args:
    ssd_config: A ssd.proto object containing the config for the desired
      SSDMetaArch.
    is_training: True if this model is being built for training purposes.
    add_summaries: Whether to add tf summaries in the model.

  Returns:
    SSDMetaArch based on the config.
  Raises:
    ValueError: If ssd_config.type is not recognized (i.e. not registered in
      model_class_map).
  """
  num_classes = ssd_config.num_classes

  # Feature extractor
  feature_extractor = _build_ssd_feature_extractor(ssd_config.feature_extractor,
                                                   is_training)

  box_coder = box_coder_builder.build(ssd_config.box_coder)
  matcher = matcher_builder.build(ssd_config.matcher)
  region_similarity_calculator = sim_calc.build(
      ssd_config.similarity_calculator)
  ssd_box_predictor = box_predictor_builder.build(hyperparams_builder.build,
                                                  ssd_config.box_predictor,
                                                  is_training, num_classes)
  anchor_generator = anchor_generator_builder.build(
      ssd_config.anchor_generator)
  image_resizer_fn = image_resizer_builder.build(ssd_config.image_resizer)
  non_max_suppression_fn, score_conversion_fn = post_processing_builder.build(
      ssd_config.post_processing)
  (classification_loss, localization_loss, classification_weight,
   localization_weight,
   hard_example_miner) = losses_builder.build(ssd_config.loss)
  normalize_loss_by_num_matches = ssd_config.normalize_loss_by_num_matches

  return ssd_meta_arch.SSDMetaArch(
      is_training,
      anchor_generator,
      ssd_box_predictor,
      box_coder,
      feature_extractor,
      matcher,
      region_similarity_calculator,
      image_resizer_fn,
      non_max_suppression_fn,
      score_conversion_fn,
      classification_loss,
      localization_loss,
      classification_weight,
      localization_weight,
      normalize_loss_by_num_matches,
      hard_example_miner,
      add_summaries=add_summaries) 
开发者ID:ShreyAmbesh,项目名称:Traffic-Rule-Violation-Detection-System,代码行数:58,代码来源:model_builder.py


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