<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/modeling/retinanet_model.py#L24-L252) |

The RetinaNet model class.

#### View aliases


**Main aliases**

[`tfm.vision.retinanet_model.RetinaNetModel`](https://www.tensorflow.org/api_docs/python/tfm/vision/models/RetinaNetModel)

<br />

    tfm.vision.models.RetinaNetModel(
        backbone: tf_keras.Model,
        decoder: tf_keras.Model,
        head: tf_keras.layers.Layer,
        detection_generator: tf_keras.layers.Layer,
        anchor_boxes: (Mapping[str, tf.Tensor] | None) = None,
        min_level: Optional[int] = None,
        max_level: Optional[int] = None,
        num_scales: Optional[int] = None,
        aspect_ratios: Optional[List[float]] = None,
        anchor_size: Optional[float] = None,
        **kwargs
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `backbone` | `tf_keras.Model` a backbone network. |
| `decoder` | `tf_keras.Model` a decoder network. |
| `head` | `RetinaNetHead`, the RetinaNet head. |
| `detection_generator` | the detection generator. |
| `anchor_boxes` | a dict of tensors which includes multilevel anchors. <br /> - key: `str`, the level of the multilevel predictions. - values: `Tensor`, the anchor coordinates of a particular feature level, whose shape is \[height_l, width_l, 4 \* num_anchors_per_location_l\]. If provided, these anchors will be used for inference (training=False). |
| `min_level` | Minimum level in output feature maps. |
| `max_level` | Maximum level in output feature maps. |
| `num_scales` | A number representing intermediate scales added on each level. For instances, num_scales=2 adds one additional intermediate anchor scales \[2\^0, 2\^0.5\] on each level. |
| `aspect_ratios` | A list representing the aspect raito anchors added on each level. The number indicates the ratio of width to height. For instances, aspect_ratios=\[1.0, 2.0, 0.5\] adds three anchors on each scale level. |
| `anchor_size` | A number representing the scale of size of the base anchor to the feature stride 2\^level. |
| `**kwargs` | keyword arguments to be passed. |

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `anchor_boxes` | <br /> <br /> |
| `backbone` | <br /> <br /> |
| `checkpoint_items` | Returns a dictionary of items to be additionally checkpointed. |
| `decoder` | <br /> <br /> |
| `detection_generator` | <br /> <br /> |
| `head` | <br /> <br /> |

<br />

## Methods

### `call`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/modeling/retinanet_model.py#L84-L215)

    call(
        images: Union[tf.Tensor, Sequence[tf.Tensor]],
        image_shape: Optional[tf.Tensor] = None,
        anchor_boxes: (Mapping[str, tf.Tensor] | None) = None,
        output_intermediate_features: bool = False,
        training: bool = None
    ) -> Mapping[str, tf.Tensor]

Forward pass of the RetinaNet model.

<br />

<br />

<br />

| Args ||
|---|---|
| `images` | `Tensor` or a sequence of `Tensor`, the input batched images to the backbone network, whose shape(s) is \[batch, height, width, 3\]. If it is a sequence of `Tensor`, we will assume the anchors are generated based on the shape of the first image(s). |
| `image_shape` | `Tensor`, the actual shape of the input images, whose shape is \[batch, 2\] where the last dimension is \[height, width\]. Note that this is the actual image shape excluding paddings. For example, images in the batch may be resized into different shapes before padding to the fixed size. |
| `anchor_boxes` | the anchor boxes to use for inference (training=False) if not provided in the init. |
| `output_intermediate_features` | `bool` indicating whether to return the intermediate feature maps generated by backbone and decoder. |
| `training` | `bool`, indicating whether it is in training mode. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| `scores` | a dict of tensors which includes scores of the predictions. <br /> - key: `str`, the level of the multilevel predictions. - values: `Tensor`, the box scores predicted from a particular feature level, whose shape is \[batch, height_l, width_l, num_classes \* num_anchors_per_location\]. |
| `boxes` | a dict of tensors which includes coordinates of the predictions. - key: `str`, the level of the multilevel predictions. - values: `Tensor`, the box coordinates predicted from a particular feature level, whose shape is \[batch, height_l, width_l, 4 \* num_anchors_per_location\]. |
| `attributes` | a dict of (attribute_name, attribute_predictions). Each attribute prediction is a dict that includes: - key: `str`, the level of the multilevel predictions. - values: `Tensor`, the attribute predictions from a particular feature level, whose shape is \[batch, height_l, width_l, att_size \* num_anchors_per_location\]. |