本文整理匯總了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)
示例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)
示例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)
示例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)