RetinaNetObjectDetector classkeras_hub.models.RetinaNetObjectDetector(
backbone,
num_classes,
bounding_box_format="yxyx",
anchor_generator=None,
label_encoder=None,
use_prediction_head_norm=False,
classification_head_prior_probability=0.01,
pre_logits_num_conv_layers=4,
preprocessor=None,
activation=None,
dtype=None,
prediction_decoder=None,
**kwargs
)
RetinaNet object detector model.
This class implements the RetinaNet object detection architecture. It consists of a feature extractor backbone, a feature pyramid network(FPN), and two prediction heads (for classification and bounding box regression).
Arguments
keras.Model. A keras.models.RetinaNetBackbone class,
defining the backbone network architecture. Provides feature maps
for detection.keras_hub.layers.AnchorGenerator instance.
Generates anchor boxes at different scales and aspect ratios
across the image. If None, a default AnchorGenerator is
created with the following parameters:
- bounding_box_format: Same as the model's
bounding_box_format.
- min_level: The backbone's min_level.
- max_level: The backbone's max_level.
- num_scales: 3.
- aspect_ratios: [0.5, 1.0, 2.0].
- anchor_size: 4.0.
You can create a custom AnchorGenerator by instantiating the
keras_hub.layers.AnchorGenerator class and passing the desired
arguments.yxyx.RetinaNetLabelEncoder instance. Encodes
ground truth boxes and classes into training targets. It matches
ground truth boxes to anchors based on IoU and encodes box
coordinates as offsets. If None, a default encoder is created.
See the RetinaNetLabelEncoder class for details. If None, a
default encoder is created with standard parameters.
- anchor_generator: Same as the model's.
- bounding_box_format: Same as the model's
bounding_box_format.
- positive_threshold: 0.5
- negative_threshold: 0.4
- encoding_format: "center_xywh"
- box_variance: [1.0, 1.0, 1.0, 1.0]
- background_class: -1
- ignore_class: -2False.RetinaNetObjectDetectorPreprocessoror a custom preprocessor.
Handles image preprocessing before feeding into the backbone.keras.layers.Layer instance
responsible for transforming RetinaNet predictions
(box regressions and classifications) into final bounding boxes and
classes with confidence scores. Defaults to a NonMaxSuppression
instance.from_preset methodRetinaNetObjectDetector.from_preset(preset, load_weights=True, **kwargs)
Instantiate a keras_hub.models.Task from a model preset.
A preset is a directory of configs, weights and other file assets used
to save and load a pre-trained model. The preset can be passed as
one of:
'bert_base_en''kaggle://user/bert/keras/bert_base_en''hf://user/bert_base_en''./bert_base_en'For any Task subclass, you can run cls.presets.keys() to list all
built-in presets available on the class.
This constructor can be called in one of two ways. Either from a task
specific base class like keras_hub.models.CausalLM.from_preset(), or
from a model class like
keras_hub.models.BertTextClassifier.from_preset().
If calling from the a base class, the subclass of the returning object
will be inferred from the config in the preset directory.
Arguments
True, saved weights will be loaded into
the model architecture. If False, all weights will be
randomly initialized.Examples
# Load a Gemma generative task.
causal_lm = keras_hub.models.CausalLM.from_preset(
"gemma_2b_en",
)
# Load a Bert classification task.
model = keras_hub.models.TextClassifier.from_preset(
"bert_base_en",
num_classes=2,
)
| Preset | Parameters | Description |
|---|---|---|
| retinanet_resnet50_fpn_v2_coco | 31.56M | RetinaNet model with ResNet50 backbone fine-tuned on COCO in 800x800 resolution with FPN features created from P5 level. |
| retinanet_resnet50_fpn_coco | 34.12M | RetinaNet model with ResNet50 backbone fine-tuned on COCO in 800x800 resolution. |
backbone propertykeras_hub.models.RetinaNetObjectDetector.backbone
A keras_hub.models.Backbone model with the core architecture.
preprocessor propertykeras_hub.models.RetinaNetObjectDetector.preprocessor
A keras_hub.models.Preprocessor layer used to preprocess input.