Exemplo n.º 1
0
    def testPadding(self):
        x_shape = [3, 4, 1]
        x_np = np.ones(x_shape, dtype=np.float32)

        offset_height = 2
        after_height = 3

        offset_width = 1
        after_width = 4

        target_height = x_shape[0] + offset_height + after_height
        target_width = x_shape[1] + offset_width + after_width

        # Note the padding are along batch, height, width and depth.
        paddings = ((offset_height, after_height), (offset_width, after_width),
                    (0, 0))

        y_np = np.pad(x_np, paddings, 'constant')

        with self.test_session():
            x = constant_op.constant(x_np, shape=x_shape)
            y = image_ops.pad_to_bounding_box(x, offset_height, offset_width,
                                              target_height, target_width)
            y_tf = y.eval()
            self.assertAllEqual(y_tf, y_np)
Exemplo n.º 2
0
  def testPadding(self):
    x_shape = [3, 4, 1]
    x_np = np.ones(x_shape, dtype=np.float32)

    offset_height = 2
    after_height = 3

    offset_width = 1
    after_width = 4

    target_height = x_shape[0] + offset_height + after_height
    target_width = x_shape[1] + offset_width + after_width

    # Note the padding are along batch, height, width and depth.
    paddings = ((offset_height, after_height),
                (offset_width, after_width),
                (0, 0))

    y_np = np.pad(x_np, paddings, 'constant')

    with self.test_session():
      x = constant_op.constant(x_np, shape=x_shape)
      y = image_ops.pad_to_bounding_box(x, offset_height, offset_width,
                                        target_height, target_width)
      y_tf = y.eval()
      self.assertAllEqual(y_tf, y_np)
Exemplo n.º 3
0
  def testNoOp(self):
    x_shape = [13, 9, 3]
    x_np = np.ones(x_shape, dtype=np.float32)

    target_height = x_shape[0]
    target_width = x_shape[1]

    with self.test_session():
      x = constant_op.constant(x_np, shape=x_shape)
      y = image_ops.pad_to_bounding_box(x, 0, 0, target_height, target_width)
      y_tf = y.eval()
      self.assertAllEqual(y_tf, x_np)
Exemplo n.º 4
0
  def testNoOp(self):
    x_shape = [13, 9, 3]
    x_np = np.ones(x_shape, dtype=np.float32)

    target_height = x_shape[0]
    target_width = x_shape[1]

    with self.test_session():
      x = constant_op.constant(x_np, shape=x_shape)
      y = image_ops.pad_to_bounding_box(x, 0, 0, target_height, target_width)
      y_tf = y.eval()
      self.assertAllEqual(y_tf, x_np)