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


Python box_list_ops.boolean_mask方法代码示例

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


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

示例1: test_boolean_mask_with_field

# 需要导入模块: from object_detection.core import box_list_ops [as 别名]
# 或者: from object_detection.core.box_list_ops import boolean_mask [as 别名]
def test_boolean_mask_with_field(self):
    corners = tf.constant(
        [4 * [0.0], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]])
    indicator = tf.constant([True, False, True, False, True], tf.bool)
    weights = tf.constant([[.1], [.3], [.5], [.7], [.9]], tf.float32)
    expected_subset = [4 * [0.0], 4 * [2.0], 4 * [4.0]]
    expected_weights = [[.1], [.5], [.9]]

    boxes = box_list.BoxList(corners)
    boxes.add_field('weights', weights)
    subset = box_list_ops.boolean_mask(boxes, indicator, ['weights'])
    with self.test_session() as sess:
      subset_output, weights_output = sess.run(
          [subset.get(), subset.get_field('weights')])
      self.assertAllClose(subset_output, expected_subset)
      self.assertAllClose(weights_output, expected_weights) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:box_list_ops_test.py

示例2: _get_refined_encodings_for_postitive_class

# 需要导入模块: from object_detection.core import box_list_ops [as 别名]
# 或者: from object_detection.core.box_list_ops import boolean_mask [as 别名]
def _get_refined_encodings_for_postitive_class(
      self, refined_box_encodings, flat_cls_targets_with_background,
      batch_size):
    # We only predict refined location encodings for the non background
    # classes, but we now pad it to make it compatible with the class
    # predictions
    refined_box_encodings_with_background = tf.pad(refined_box_encodings,
                                                   [[0, 0], [1, 0], [0, 0]])
    refined_box_encodings_masked_by_class_targets = (
        box_list_ops.boolean_mask(
            box_list.BoxList(
                tf.reshape(refined_box_encodings_with_background,
                           [-1, self._box_coder.code_size])),
            tf.reshape(tf.greater(flat_cls_targets_with_background, 0), [-1]),
            use_static_shapes=self._use_static_shapes,
            indicator_sum=batch_size * self.max_num_proposals
            if self._use_static_shapes else None).get())
    return tf.reshape(
        refined_box_encodings_masked_by_class_targets, [
            batch_size, self.max_num_proposals,
            self._box_coder.code_size
        ]) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:24,代码来源:faster_rcnn_meta_arch.py

示例3: test_static_boolean_mask_with_field

# 需要导入模块: from object_detection.core import box_list_ops [as 别名]
# 或者: from object_detection.core.box_list_ops import boolean_mask [as 别名]
def test_static_boolean_mask_with_field(self):

    def graph_fn(corners, weights, indicator):
      boxes = box_list.BoxList(corners)
      boxes.add_field('weights', weights)
      subset = box_list_ops.boolean_mask(
          boxes,
          indicator, ['weights'],
          use_static_shapes=True,
          indicator_sum=3)
      return (subset.get_field('boxes'), subset.get_field('weights'))

    corners = np.array(
        [4 * [0.0], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]],
        dtype=np.float32)
    indicator = np.array([True, False, True, False, True], dtype=np.bool)
    weights = np.array([[.1], [.3], [.5], [.7], [.9]], dtype=np.float32)
    result_boxes, result_weights = self.execute(graph_fn,
                                                [corners, weights, indicator])
    expected_boxes = [4 * [0.0], 4 * [2.0], 4 * [4.0]]
    expected_weights = [[.1], [.5], [.9]]

    self.assertAllClose(result_boxes, expected_boxes)
    self.assertAllClose(result_weights, expected_weights) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:26,代码来源:box_list_ops_test.py

示例4: test_dynamic_boolean_mask_with_field

# 需要导入模块: from object_detection.core import box_list_ops [as 别名]
# 或者: from object_detection.core.box_list_ops import boolean_mask [as 别名]
def test_dynamic_boolean_mask_with_field(self):
    corners = tf.placeholder(tf.float32, [None, 4])
    indicator = tf.placeholder(tf.bool, [None])
    weights = tf.placeholder(tf.float32, [None, 1])
    expected_subset = [4 * [0.0], 4 * [2.0], 4 * [4.0]]
    expected_weights = [[.1], [.5], [.9]]

    boxes = box_list.BoxList(corners)
    boxes.add_field('weights', weights)
    subset = box_list_ops.boolean_mask(boxes, indicator, ['weights'])
    with self.test_session() as sess:
      subset_output, weights_output = sess.run(
          [subset.get(), subset.get_field('weights')],
          feed_dict={
              corners:
                  np.array(
                      [4 * [0.0], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]]),
              indicator:
                  np.array([True, False, True, False, True]).astype(np.bool),
              weights:
                  np.array([[.1], [.3], [.5], [.7], [.9]])
          })
      self.assertAllClose(subset_output, expected_subset)
      self.assertAllClose(weights_output, expected_weights) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:26,代码来源:box_list_ops_test.py

示例5: test_boolean_mask_with_field

# 需要导入模块: from object_detection.core import box_list_ops [as 别名]
# 或者: from object_detection.core.box_list_ops import boolean_mask [as 别名]
def test_boolean_mask_with_field(self):
        corners = tf.constant(
            [4 * [0.0], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]])
        indicator = tf.constant([True, False, True, False, True], tf.bool)
        weights = tf.constant([[.1], [.3], [.5], [.7], [.9]], tf.float32)
        expected_subset = [4 * [0.0], 4 * [2.0], 4 * [4.0]]
        expected_weights = [[.1], [.5], [.9]]

        boxes = box_list.BoxList(corners)
        boxes.add_field('weights', weights)
        subset = box_list_ops.boolean_mask(boxes, indicator, ['weights'])
        with self.test_session() as sess:
            subset_output, weights_output = sess.run(
                [subset.get(), subset.get_field('weights')])
            self.assertAllClose(subset_output, expected_subset)
            self.assertAllClose(weights_output, expected_weights) 
开发者ID:kujason,项目名称:monopsr,代码行数:18,代码来源:box_list_ops_test.py


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