RetinaNetBackbone
classkeras_hub.models.RetinaNetBackbone(
image_encoder,
min_level,
max_level,
use_p5,
use_fpn_batch_norm=False,
image_shape=(None, None, 3),
data_format=None,
dtype=None,
**kwargs
)
RetinaNet Backbone.
Combines a CNN backbone (e.g., ResNet, MobileNet) with a feature pyramid network (FPN)to extract multi-scale features for object detection.
Arguments
keras.Model
. The backbone model (e.g., ResNet50,
MobileNetV2) used to extract features from the input image.
It should have pyramid outputs (i.e., a dictionary mapping level
names like "P2"
, "P3"
, etc. to their corresponding feature
tensors).True
, the output of the last backbone
layer (typically 'P5'
in an FPN) is used as input to create
higher-level feature maps (e.g., 'P6'
, 'P7'
) through
additional convolutional layers. If False
, the original 'P5'
feature map from the backbone is directly used as input for
creating the coarser levels, bypassing any further processing of
'P5'
within the feature pyramid. Defaults to False
.False
.None
if they are variable.Raises
min_level
is greater than max_level
.backbone_max_level
is less than 5 and max_level
is
greater than or equal to 5.from_preset
methodRetinaNetBackbone.from_preset(preset, load_weights=True, **kwargs)
Instantiate a keras_hub.models.Backbone
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 a
one of:
'bert_base_en'
'kaggle://user/bert/keras/bert_base_en'
'hf://user/bert_base_en'
'./bert_base_en'
This constructor can be called in one of two ways. Either from the base
class like keras_hub.models.Backbone.from_preset()
, or from
a model class like keras_hub.models.GemmaBackbone.from_preset()
.
If calling from the base class, the subclass of the returning object
will be inferred from the config in the preset directory.
For any Backbone
subclass, you can run cls.presets.keys()
to list
all built-in presets available on the class.
Arguments
True
, the weights will be loaded into the
model architecture. If False
, the weights will be randomly
initialized.Examples
# Load a Gemma backbone with pre-trained weights.
model = keras_hub.models.Backbone.from_preset(
"gemma_2b_en",
)
# Load a Bert backbone with a pre-trained config and random weights.
model = keras_hub.models.Backbone.from_preset(
"bert_base_en",
load_weights=False,
)
Preset | Parameters | Description |
---|---|---|
retinanet_resnet50_fpn_coco | 34.12M | RetinaNet model with ResNet50 backbone fine-tuned on COCO in 800x800 resolution. |