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


Python ops.dense_to_sparse_boxes方法代碼示例

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


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

示例1: test_return_all_boxes_when_all_input_boxes_are_valid

# 需要導入模塊: from object_detection.utils import ops [as 別名]
# 或者: from object_detection.utils.ops import dense_to_sparse_boxes [as 別名]
def test_return_all_boxes_when_all_input_boxes_are_valid(self):
    num_classes = 4
    num_valid_boxes = 3
    code_size = 4
    dense_location_placeholder = tf.placeholder(tf.float32,
                                                shape=(num_valid_boxes,
                                                       code_size))
    dense_num_boxes_placeholder = tf.placeholder(tf.int32, shape=(num_classes))
    box_locations, box_classes = ops.dense_to_sparse_boxes(
        dense_location_placeholder, dense_num_boxes_placeholder, num_classes)
    feed_dict = {dense_location_placeholder: np.random.uniform(
        size=[num_valid_boxes, code_size]),
                 dense_num_boxes_placeholder: np.array([1, 0, 0, 2],
                                                       dtype=np.int32)}

    expected_box_locations = feed_dict[dense_location_placeholder]
    expected_box_classses = np.array([0, 3, 3])
    with self.test_session() as sess:
      box_locations, box_classes = sess.run([box_locations, box_classes],
                                            feed_dict=feed_dict)

    self.assertAllClose(box_locations, expected_box_locations, rtol=1e-6,
                        atol=1e-6)
    self.assertAllEqual(box_classes, expected_box_classses) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:26,代碼來源:ops_test.py

示例2: test_return_all_boxes_when_all_input_boxes_are_valid

# 需要導入模塊: from object_detection.utils import ops [as 別名]
# 或者: from object_detection.utils.ops import dense_to_sparse_boxes [as 別名]
def test_return_all_boxes_when_all_input_boxes_are_valid(self):
        num_classes = 4
        num_valid_boxes = 3
        code_size = 4
        dense_location_placeholder = tf.placeholder(tf.float32,
                                                    shape=(num_valid_boxes,
                                                           code_size))
        dense_num_boxes_placeholder = tf.placeholder(tf.int32, shape=(num_classes))
        box_locations, box_classes = ops.dense_to_sparse_boxes(
            dense_location_placeholder, dense_num_boxes_placeholder, num_classes)
        feed_dict = {dense_location_placeholder: np.random.uniform(
            size=[num_valid_boxes, code_size]),
            dense_num_boxes_placeholder: np.array([1, 0, 0, 2],
                                                  dtype=np.int32)}

        expected_box_locations = feed_dict[dense_location_placeholder]
        expected_box_classses = np.array([0, 3, 3])
        with self.test_session() as sess:
            box_locations, box_classes = sess.run([box_locations, box_classes],
                                                  feed_dict=feed_dict)

        self.assertAllClose(box_locations, expected_box_locations, rtol=1e-6,
                            atol=1e-6)
        self.assertAllEqual(box_classes, expected_box_classses) 
開發者ID:kujason,項目名稱:monopsr,代碼行數:26,代碼來源:ops_test.py

示例3: test_return_all_boxes_when_all_input_boxes_are_valid

# 需要導入模塊: from object_detection.utils import ops [as 別名]
# 或者: from object_detection.utils.ops import dense_to_sparse_boxes [as 別名]
def test_return_all_boxes_when_all_input_boxes_are_valid(self):
    num_classes = 4
    num_valid_boxes = 3
    code_size = 4

    def graph_fn(dense_location, dense_num_boxes):
      box_locations, box_classes = ops.dense_to_sparse_boxes(
          dense_location, dense_num_boxes, num_classes)
      return box_locations, box_classes

    dense_location_np = np.random.uniform(size=[num_valid_boxes, code_size])
    dense_num_boxes_np = np.array([1, 0, 0, 2], dtype=np.int32)

    expected_box_locations = dense_location_np
    expected_box_classses = np.array([0, 3, 3])

    # Executing on CPU only since output shape is not constant.
    box_locations, box_classes = self.execute_cpu(
        graph_fn, [dense_location_np, dense_num_boxes_np])

    self.assertAllClose(box_locations, expected_box_locations, rtol=1e-6,
                        atol=1e-6)
    self.assertAllEqual(box_classes, expected_box_classses) 
開發者ID:tensorflow,項目名稱:models,代碼行數:25,代碼來源:ops_test.py

示例4: test_return_only_valid_boxes_when_input_contains_invalid_boxes

# 需要導入模塊: from object_detection.utils import ops [as 別名]
# 或者: from object_detection.utils.ops import dense_to_sparse_boxes [as 別名]
def test_return_only_valid_boxes_when_input_contains_invalid_boxes(self):
    num_classes = 4
    num_valid_boxes = 3
    num_boxes = 10
    code_size = 4

    def graph_fn(dense_location, dense_num_boxes):
      box_locations, box_classes = ops.dense_to_sparse_boxes(
          dense_location, dense_num_boxes, num_classes)
      return box_locations, box_classes

    dense_location_np = np.random.uniform(size=[num_boxes, code_size])
    dense_num_boxes_np = np.array([1, 0, 0, 2], dtype=np.int32)

    expected_box_locations = dense_location_np[:num_valid_boxes]
    expected_box_classses = np.array([0, 3, 3])

    # Executing on CPU only since output shape is not constant.
    box_locations, box_classes = self.execute_cpu(
        graph_fn, [dense_location_np, dense_num_boxes_np])

    self.assertAllClose(box_locations, expected_box_locations, rtol=1e-6,
                        atol=1e-6)
    self.assertAllEqual(box_classes, expected_box_classses) 
開發者ID:tensorflow,項目名稱:models,代碼行數:26,代碼來源:ops_test.py


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