EfficientNetV2Backbone
classkeras_cv.models.EfficientNetV2Backbone(
include_rescaling,
width_coefficient,
depth_coefficient,
stackwise_kernel_sizes,
stackwise_num_repeats,
stackwise_input_filters,
stackwise_output_filters,
stackwise_expansion_ratios,
stackwise_squeeze_and_excite_ratios,
stackwise_strides,
stackwise_conv_types,
skip_connection_dropout=0.2,
depth_divisor=8,
min_depth=8,
activation="swish",
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
Instantiates the EfficientNetV2 architecture.
Reference
Arguments
True
, inputs will be passed through a Rescaling(1/255.0)
layer.keras.layers.Input()
)
to use as image input for the model.Example
# Construct an EfficientNetV2 from a preset:
efficientnet = keras_cv.models.EfficientNetV2Backbone.from_preset(
"efficientnetv2_s"
)
images = tf.ones((1, 256, 256, 3))
outputs = efficientnet.predict(images)
# Alternatively, you can also customize the EfficientNetV2 architecture:
model = EfficientNetV2Backbone(
stackwise_kernel_sizes=[3, 3, 3, 3, 3, 3],
stackwise_num_repeats=[2, 4, 4, 6, 9, 15],
stackwise_input_filters=[24, 24, 48, 64, 128, 160],
stackwise_output_filters=[24, 48, 64, 128, 160, 256],
stackwise_expansion_ratios=[1, 4, 4, 4, 6, 6],
stackwise_squeeze_and_excite_ratios=[0.0, 0.0, 0, 0.25, 0.25, 0.25],
stackwise_strides=[1, 2, 2, 2, 1, 2],
stackwise_conv_types=[
"fused",
"fused",
"fused",
"unfused",
"unfused",
"unfused",
],
width_coefficient=1.0,
depth_coefficient=1.0,
include_rescaling=False,
)
images = tf.ones((1, 256, 256, 3))
outputs = efficientnet.predict(images)
from_preset
methodEfficientNetV2Backbone.from_preset()
Instantiate EfficientNetV2Backbone model from preset config and weights.
Arguments
None
, which follows whether the preset has
pretrained weights available.Examples
# Load architecture and weights from preset
model = keras_cv.models.EfficientNetV2Backbone.from_preset(
"efficientnetv2_s_imagenet",
)
# Load randomly initialized model from preset architecture with weights
model = keras_cv.models.EfficientNetV2Backbone.from_preset(
"efficientnetv2_s_imagenet",
load_weights=False,
Preset name | Parameters | Description |
---|---|---|
efficientnetv2_s | 20.33M | EfficientNet architecture with 6 convolutional blocks. |
efficientnetv2_m | 53.15M | EfficientNet architecture with 7 convolutional blocks. |
efficientnetv2_l | 117.75M | EfficientNet architecture with 7 convolutional blocks, but more filters the in efficientnetv2_m . |
efficientnetv2_b0 | 5.92M | EfficientNet B-style architecture with 6 convolutional blocks. This B-style model has width_coefficient=1.0 and depth_coefficient=1.0 . |
efficientnetv2_b1 | 6.93M | EfficientNet B-style architecture with 6 convolutional blocks. This B-style model has width_coefficient=1.0 and depth_coefficient=1.1 . |
efficientnetv2_b2 | 8.77M | EfficientNet B-style architecture with 6 convolutional blocks. This B-style model has width_coefficient=1.1 and depth_coefficient=1.2 . |
efficientnetv2_b3 | 12.93M | EfficientNet B-style architecture with 7 convolutional blocks. This B-style model has width_coefficient=1.2 and depth_coefficient=1.4 . |
efficientnetv2_s_imagenet | 20.33M | EfficientNet architecture with 6 convolutional blocks. Weights are initialized to pretrained imagenet classification weights.Published weights are capable of scoring 83.9%top 1 accuracy and 96.7% top 5 accuracy on imagenet. |
efficientnetv2_b0_imagenet | 5.92M | EfficientNet B-style architecture with 6 convolutional blocks. This B-style model has width_coefficient=1.0 and depth_coefficient=1.0 . Weights are initialized to pretrained imagenet classification weights. Published weights are capable of scoring 77.1% top 1 accuracy and 93.3% top 5 accuracy on imagenet. |
efficientnetv2_b1_imagenet | 6.93M | EfficientNet B-style architecture with 6 convolutional blocks. This B-style model has width_coefficient=1.0 and depth_coefficient=1.1 . Weights are initialized to pretrained imagenet classification weights.Published weights are capable of scoring 79.1% top 1 accuracy and 94.4% top 5 accuracy on imagenet. |
efficientnetv2_b2_imagenet | 8.77M | EfficientNet B-style architecture with 6 convolutional blocks. This B-style model has width_coefficient=1.1 and depth_coefficient=1.2 . Weights are initialized to pretrained imagenet classification weights.Published weights are capable of scoring 80.1% top 1 accuracy and 94.9% top 5 accuracy on imagenet. |
EfficientNetV2B0Backbone
classkeras_cv.models.EfficientNetV2B0Backbone(
include_rescaling,
width_coefficient,
depth_coefficient,
stackwise_kernel_sizes,
stackwise_num_repeats,
stackwise_input_filters,
stackwise_output_filters,
stackwise_expansion_ratios,
stackwise_squeeze_and_excite_ratios,
stackwise_strides,
stackwise_conv_types,
skip_connection_dropout=0.2,
depth_divisor=8,
min_depth=8,
activation="swish",
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
Instantiates the EfficientNetV2B0 architecture.
Reference
Arguments
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.EfficientNetV2B1Backbone
classkeras_cv.models.EfficientNetV2B1Backbone(
include_rescaling,
width_coefficient,
depth_coefficient,
stackwise_kernel_sizes,
stackwise_num_repeats,
stackwise_input_filters,
stackwise_output_filters,
stackwise_expansion_ratios,
stackwise_squeeze_and_excite_ratios,
stackwise_strides,
stackwise_conv_types,
skip_connection_dropout=0.2,
depth_divisor=8,
min_depth=8,
activation="swish",
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
Instantiates the EfficientNetV2B1 architecture.
Reference
Arguments
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.EfficientNetV2B2Backbone
classkeras_cv.models.EfficientNetV2B2Backbone(
include_rescaling,
width_coefficient,
depth_coefficient,
stackwise_kernel_sizes,
stackwise_num_repeats,
stackwise_input_filters,
stackwise_output_filters,
stackwise_expansion_ratios,
stackwise_squeeze_and_excite_ratios,
stackwise_strides,
stackwise_conv_types,
skip_connection_dropout=0.2,
depth_divisor=8,
min_depth=8,
activation="swish",
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
Instantiates the EfficientNetV2B2 architecture.
Reference
Arguments
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.EfficientNetV2B3Backbone
classkeras_cv.models.EfficientNetV2B3Backbone(
include_rescaling,
width_coefficient,
depth_coefficient,
stackwise_kernel_sizes,
stackwise_num_repeats,
stackwise_input_filters,
stackwise_output_filters,
stackwise_expansion_ratios,
stackwise_squeeze_and_excite_ratios,
stackwise_strides,
stackwise_conv_types,
skip_connection_dropout=0.2,
depth_divisor=8,
min_depth=8,
activation="swish",
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
Instantiates the EfficientNetV2B3 architecture.
Reference
Arguments
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.EfficientNetV2SBackbone
classkeras_cv.models.EfficientNetV2SBackbone(
include_rescaling,
width_coefficient,
depth_coefficient,
stackwise_kernel_sizes,
stackwise_num_repeats,
stackwise_input_filters,
stackwise_output_filters,
stackwise_expansion_ratios,
stackwise_squeeze_and_excite_ratios,
stackwise_strides,
stackwise_conv_types,
skip_connection_dropout=0.2,
depth_divisor=8,
min_depth=8,
activation="swish",
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
Instantiates the EfficientNetV2S architecture.
Reference
Arguments
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.EfficientNetV2MBackbone
classkeras_cv.models.EfficientNetV2MBackbone(
include_rescaling,
width_coefficient,
depth_coefficient,
stackwise_kernel_sizes,
stackwise_num_repeats,
stackwise_input_filters,
stackwise_output_filters,
stackwise_expansion_ratios,
stackwise_squeeze_and_excite_ratios,
stackwise_strides,
stackwise_conv_types,
skip_connection_dropout=0.2,
depth_divisor=8,
min_depth=8,
activation="swish",
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
Instantiates the EfficientNetV2M architecture.
Reference
Arguments
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.EfficientNetV2LBackbone
classkeras_cv.models.EfficientNetV2LBackbone(
include_rescaling,
width_coefficient,
depth_coefficient,
stackwise_kernel_sizes,
stackwise_num_repeats,
stackwise_input_filters,
stackwise_output_filters,
stackwise_expansion_ratios,
stackwise_squeeze_and_excite_ratios,
stackwise_strides,
stackwise_conv_types,
skip_connection_dropout=0.2,
depth_divisor=8,
min_depth=8,
activation="swish",
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
Instantiates the EfficientNetV2L architecture.
Reference
Arguments
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.