prior_box prior_box ( input, image, min_sizes, max_sizes=None, aspect_ratios=[1.0], variance=[0.1, 0.1, 0.2, 0.2], flip=False, clip=False, steps=[0.0, 0.0], offset=0.5, min_max_aspect_ratios_order=False, name=None ) [source]

This op generates prior boxes for SSD(Single Shot MultiBox Detector) algorithm.

Each position of the input produce N prior boxes, N is determined by the count of min_sizes, max_sizes and aspect_ratios, The size of the box is in range(min_size, max_size) interval, which is generated in sequence according to the aspect_ratios.

  • input (Tensor) – 4-D tensor(NCHW), the data type should be float32 or float64.

  • image (Tensor) – 4-D tensor(NCHW), the input image data of PriorBoxOp, the data type should be float32 or float64.

  • min_sizes (list|tuple|float) – the min sizes of generated prior boxes.

  • max_sizes (list|tuple|None, optional) – the max sizes of generated prior boxes. Default: None, means [] and will not be used.

  • aspect_ratios (list|tuple|float, optional) – the aspect ratios of generated prior boxes. Default: [1.0].

  • variance (list|tuple, optional) – the variances to be encoded in prior boxes. Default:[0.1, 0.1, 0.2, 0.2].

  • flip (bool) – Whether to flip aspect ratios. Default:False.

  • clip (bool) – Whether to clip out-of-boundary boxes. Default: False.

  • steps (list|tuple, optional) – Prior boxes steps across width and height, If steps[0] equals to 0.0 or steps[1] equals to 0.0, the prior boxes steps across height or weight of the input will be automatically calculated. Default: [0., 0.]

  • offset (float, optional)) – Prior boxes center offset. Default: 0.5

  • min_max_aspect_ratios_order (bool, optional) – If set True, the output prior box is in order of [min, max, aspect_ratios], which is consistent with Caffe. Please note, this order affects the weights order of convolution layer followed by and does not affect the final detection results. Default: False.

  • name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name


the output prior boxes and the expanded variances of PriorBox.

The prior boxes is a 4-D tensor, the layout is [H, W, num_priors, 4], num_priors is the total box count of each position of input. The expanded variances is a 4-D tensor, same shape as the prior boxes.

Return type



>>> import paddle

>>> input = paddle.rand((1, 3, 6, 9), dtype=paddle.float32)
>>> image = paddle.rand((1, 3, 9, 12), dtype=paddle.float32)
>>> box, var =
...     input=input,
...     image=image,
...     min_sizes=[2.0, 4.0],
...     clip=True,
...     flip=True)