本文整理匯總了Python中object_detection.utils.ops.reframe_box_masks_to_image_masks方法的典型用法代碼示例。如果您正苦於以下問題:Python ops.reframe_box_masks_to_image_masks方法的具體用法?Python ops.reframe_box_masks_to_image_masks怎麽用?Python ops.reframe_box_masks_to_image_masks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類object_detection.utils.ops
的用法示例。
在下文中一共展示了ops.reframe_box_masks_to_image_masks方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testZeroImageOnEmptyMask
# 需要導入模塊: from object_detection.utils import ops [as 別名]
# 或者: from object_detection.utils.ops import reframe_box_masks_to_image_masks [as 別名]
def testZeroImageOnEmptyMask(self):
box_masks = tf.constant([[[0, 0],
[0, 0]]], dtype=tf.float32)
boxes = tf.constant([[0.0, 0.0, 1.0, 1.0]], dtype=tf.float32)
image_masks = ops.reframe_box_masks_to_image_masks(box_masks, boxes,
image_height=4,
image_width=4)
np_expected_image_masks = np.array([[[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]]], dtype=np.float32)
with self.test_session() as sess:
np_image_masks = sess.run(image_masks)
self.assertAllClose(np_image_masks, np_expected_image_masks)
示例2: testMaskIsCenteredInImageWhenBoxIsCentered
# 需要導入模塊: from object_detection.utils import ops [as 別名]
# 或者: from object_detection.utils.ops import reframe_box_masks_to_image_masks [as 別名]
def testMaskIsCenteredInImageWhenBoxIsCentered(self):
box_masks = tf.constant([[[1, 1],
[1, 1]]], dtype=tf.float32)
boxes = tf.constant([[0.25, 0.25, 0.75, 0.75]], dtype=tf.float32)
image_masks = ops.reframe_box_masks_to_image_masks(box_masks, boxes,
image_height=4,
image_width=4)
np_expected_image_masks = np.array([[[0, 0, 0, 0],
[0, 1, 1, 0],
[0, 1, 1, 0],
[0, 0, 0, 0]]], dtype=np.float32)
with self.test_session() as sess:
np_image_masks = sess.run(image_masks)
self.assertAllClose(np_image_masks, np_expected_image_masks)
示例3: testMaskOffCenterRemainsOffCenterInImage
# 需要導入模塊: from object_detection.utils import ops [as 別名]
# 或者: from object_detection.utils.ops import reframe_box_masks_to_image_masks [as 別名]
def testMaskOffCenterRemainsOffCenterInImage(self):
box_masks = tf.constant([[[1, 0],
[0, 1]]], dtype=tf.float32)
boxes = tf.constant([[0.25, 0.5, 0.75, 1.0]], dtype=tf.float32)
image_masks = ops.reframe_box_masks_to_image_masks(box_masks, boxes,
image_height=4,
image_width=4)
np_expected_image_masks = np.array([[[0, 0, 0, 0],
[0, 0, 0.6111111, 0.16666669],
[0, 0, 0.3888889, 0.83333337],
[0, 0, 0, 0]]], dtype=np.float32)
with self.test_session() as sess:
np_image_masks = sess.run(image_masks)
self.assertAllClose(np_image_masks, np_expected_image_masks)
示例4: _resize_detection_masks
# 需要導入模塊: from object_detection.utils import ops [as 別名]
# 或者: from object_detection.utils.ops import reframe_box_masks_to_image_masks [as 別名]
def _resize_detection_masks(args):
detection_boxes, detection_masks, image_shape = args
detection_masks_reframed = ops.reframe_box_masks_to_image_masks(
detection_masks, detection_boxes, image_shape[0], image_shape[1])
return tf.cast(tf.greater(detection_masks_reframed, 0.5), tf.uint8)
示例5: testZeroBoxMasks
# 需要導入模塊: from object_detection.utils import ops [as 別名]
# 或者: from object_detection.utils.ops import reframe_box_masks_to_image_masks [as 別名]
def testZeroBoxMasks(self):
box_masks = tf.zeros([0, 3, 3], dtype=tf.float32)
boxes = tf.zeros([0, 4], dtype=tf.float32)
image_masks = ops.reframe_box_masks_to_image_masks(box_masks, boxes,
image_height=4,
image_width=4)
with self.test_session() as sess:
np_image_masks = sess.run(image_masks)
self.assertAllEqual(np_image_masks.shape, np.array([0, 4, 4]))