RoIAlign

class paddle.vision.ops. RoIAlign ( output_size, spatial_scale=1.0 ) [source]

This interface is used to construct a callable object of the RoIAlign class. Please refer to roi_align.

Parameters
  • output_size (int or tuple[int, int]) – The pooled output size(h, w), data type is int32. If int, h and w are both equal to output_size.

  • spatial_scale (float32, optional) – Multiplicative spatial scale factor to translate ROI coords from their input scale to the scale used when pooling. Default: 1.0

Returns

The output of ROIAlign operator is a 4-D tensor with

shape (num_boxes, channels, pooled_h, pooled_w).

Examples

import paddle
from paddle.vision.ops import RoIAlign

data = paddle.rand([1, 256, 32, 32])
boxes = paddle.rand([3, 4])
boxes[:, 2] += boxes[:, 0] + 3
boxes[:, 3] += boxes[:, 1] + 4
boxes_num = paddle.to_tensor([3]).astype('int32')
roi_align = RoIAlign(output_size=(4, 3))
align_out = roi_align(data, boxes, boxes_num)
assert align_out.shape == [3, 256, 4, 3]
forward ( x, boxes, boxes_num, aligned=True )

forward

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments