DeepLabV3Backbone model
- 원본 링크 : https://keras.io/api/keras_hub/models/deeplab_v3/deeplab_v3_backbone/
- 최종 확인 : 2024-11-25
DeepLabV3Backbone class
keras_hub.models.DeepLabV3Backbone(
    image_encoder,
    spatial_pyramid_pooling_key,
    upsampling_size,
    dilation_rates,
    low_level_feature_key=None,
    projection_filters=48,
    image_shape=(None, None, 3),
    **kwargs
)DeepLabV3 & DeepLabV3Plus architecture for semantic segmentation.
This class implements a DeepLabV3 & DeepLabV3Plus architecture as described in Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation(ECCV 2018) and Rethinking Atrous Convolution for Semantic Image Segmentation(CVPR 2017)
Arguments
- image_encoder: keras.Model. An instance that is used as a feature extractor for the Encoder. Should either be akeras_hub.models.Backboneor akeras.Modelthat implements thepyramid_outputsproperty with keys “P2”, “P3” etc as values. A somewhat sensible backbone to use in many cases is thekeras_hub.models.ResNetBackbone.from_preset("resnet_v2_50").
- projection_filters: int. Number of filters in the convolution layer
projecting low-level features from the image_encoder.
- spatial_pyramid_pooling_key: str. A layer level to extract and perform
spatial_pyramid_pooling, one of the key from theimage_encoderpyramid_outputsproperty such as “P4”, “P5” etc.
- upsampling_size: int or tuple of 2 integers. The upsampling factors for
rows and columns of spatial_pyramid_poolinglayer. Iflow_level_feature_keyis given thenspatial_pyramid_poolings layer resolution should match with thelow_level_features layer resolution to concatenate both the layers for combined encoder outputs.
- dilation_rates: list. A listof integers for parallel dilated conv applied toSpatialPyramidPooling. Usually a sample choice of rates are[6, 12, 18].
- low_level_feature_key: str optional. A layer level to extract the feature
from one of the key from the image_encoderspyramid_outputsproperty such as “P2”, “P3” etc which will be the Decoder block. Required only when the DeepLabV3Plus architecture needs to be applied.
- image_shape: tuple. The input shape without the batch size.
Defaults to (None, None, 3).
Example
# Load a trained backbone to extract features from it's `pyramid_outputs`.
image_encoder = keras_hub.models.ResNetBackbone.from_preset("resnet_50_imagenet")
model = keras_hub.models.DeepLabV3Backbone(
    image_encoder=image_encoder,
    projection_filters=48,
    low_level_feature_key="P2",
    spatial_pyramid_pooling_key="P5",
    upsampling_size = 8,
    dilation_rates = [6, 12, 18]
)from_preset method
DeepLabV3Backbone.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:
- a built-in preset identifier like 'bert_base_en'
- a Kaggle Models handle like 'kaggle://user/bert/keras/bert_base_en'
- a Hugging Face handle like 'hf://user/bert_base_en'
- a path to a local preset directory like './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
- preset: string. A built-in preset identifier, a Kaggle Models handle, a Hugging Face handle, or a path to a local directory.
- load_weights: bool. If True, the weights will be loaded into the model architecture. IfFalse, 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 name | Parameters | Description | 
|---|---|---|
| deeplab_v3_plus_resnet50_pascalvoc | 39.19M | DeepLabV3+ model with ResNet50 as image encoder and trained on augmented Pascal VOC dataset by Semantic Boundaries Dataset(SBD)which is having categorical accuracy of 90.01 and 0.63 Mean IoU. |