本文整理汇总了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)