CSPDarkNet backbones
- Original Link : https://keras.io/api/keras_cv/models/backbones/csp_darknet/
- Last Checked at : 2024-11-25
CSPDarkNetBackbone
class
keras_cv.models.CSPDarkNetBackbone(
stackwise_channels,
stackwise_depth,
include_rescaling,
use_depthwise=False,
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
This class represents the CSPDarkNet architecture.
Reference
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Arguments
- stackwise_channels: A list of ints, the number of channels for each dark level in the model.
- stackwise_depth: A list of ints, the depth for each dark level in the model.
- include_rescaling: bool, whether to rescale the inputs. If set to
True, inputs will be passed through a
Rescaling(1/255.0)
layer. - use_depthwise: bool, whether a
DarknetConvBlockDepthwise
should be used over aDarknetConvBlock
, defaults to False. - input_shape: optional shape tuple, defaults to (None, None, 3).
- input_tensor: optional Keras tensor (i.e. output of
keras.layers.Input()
) to use as image input for the model.
Returns
A keras.Model
instance.
Examples
input_data = tf.ones(shape=(8, 224, 224, 3))
# Pretrained backbone
model = keras_cv.models.CSPDarkNetBackbone.from_preset(
"csp_darknet_tiny_imagenet"
)
output = model(input_data)
# Randomly initialized backbone with a custom config
model = keras_cv.models.CSPDarkNetBackbone(
stackwise_channels=[128, 256, 512, 1024],
stackwise_depth=[3, 9, 9, 3],
include_rescaling=False,
)
output = model(input_data)
from_preset
method
CSPDarkNetBackbone.from_preset()
Instantiate CSPDarkNetBackbone model from preset config and weights.
Arguments
- preset: string. Must be one of “csp_darknet_tiny”, “csp_darknet_s”, “csp_darknet_m”, “csp_darknet_l”, “csp_darknet_xl”, “csp_darknet_tiny_imagenet”, “csp_darknet_l_imagenet”. If looking for a preset with pretrained weights, choose one of “csp_darknet_tiny_imagenet”, “csp_darknet_l_imagenet”.
- load_weights: Whether to load pre-trained weights into model.
Defaults to
None
, which follows whether the preset has pretrained weights available.
Examples
# Load architecture and weights from preset
model = keras_cv.models.CSPDarkNetBackbone.from_preset(
"csp_darknet_tiny_imagenet",
)
# Load randomly initialized model from preset architecture with weights
model = keras_cv.models.CSPDarkNetBackbone.from_preset(
"csp_darknet_tiny_imagenet",
load_weights=False,
Preset name | Parameters | Description |
---|---|---|
csp_darknet_tiny | 2.38M | CSPDarkNet model with [48, 96, 192, 384] channels and [1, 3, 3, 1] depths where the batch normalization and SiLU activation are applied after the convolution layers. |
csp_darknet_s | 4.22M | CSPDarkNet model with [64, 128, 256, 512] channels and [1, 3, 3, 1] depths where the batch normalization and SiLU activation are applied after the convolution layers. |
csp_darknet_m | 12.37M | CSPDarkNet model with [96, 192, 384, 768] channels and [2, 6, 6, 2] depths where the batch normalization and SiLU activation are applied after the convolution layers. |
csp_darknet_l | 27.11M | CSPDarkNet model with [128, 256, 512, 1024] channels and [3, 9, 9, 3] depths where the batch normalization and SiLU activation are applied after the convolution layers. |
csp_darknet_xl | 56.84M | CSPDarkNet model with [170, 340, 680, 1360] channels and [4, 12, 12, 4] depths where the batch normalization and SiLU activation are applied after the convolution layers. |
csp_darknet_tiny_imagenet | 2.38M | CSPDarkNet model with [48, 96, 192, 384] channels and [1, 3, 3, 1] depths where the batch normalization and SiLU activation are applied after the convolution layers. Trained on Imagenet 2012 classification task. |
csp_darknet_l_imagenet | 27.11M | CSPDarkNet model with [128, 256, 512, 1024] channels and [3, 9, 9, 3] depths where the batch normalization and SiLU activation are applied after the convolution layers. Trained on Imagenet 2012 classification task. |
CSPDarkNetTinyBackbone
class
keras_cv.models.CSPDarkNetTinyBackbone(
stackwise_channels,
stackwise_depth,
include_rescaling,
use_depthwise=False,
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
CSPDarkNetBackbone model with [48, 96, 192, 384] channels and [1, 3, 3, 1] depths.
Reference
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Arguments
- include_rescaling: bool, whether or not to rescale the inputs. If set to
True, inputs will be passed through a
Rescaling(1/255.0)
layer. - input_tensor: optional Keras tensor (i.e. output of
layers.Input()
) to use as image input for the model. - input_shape: optional shape tuple, defaults to (None, None, 3).
Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = CSPDarkNetTinyBackbone()
output = model(input_data)
CSPDarkNetSBackbone
class
keras_cv.models.CSPDarkNetSBackbone(
stackwise_channels,
stackwise_depth,
include_rescaling,
use_depthwise=False,
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
CSPDarkNetBackbone model with [64, 128, 256, 512] channels and [1, 3, 3, 1] depths.
Reference
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Arguments
- include_rescaling: bool, whether or not to rescale the inputs. If set to
True, inputs will be passed through a
Rescaling(1/255.0)
layer. - input_tensor: optional Keras tensor (i.e. output of
layers.Input()
) to use as image input for the model. - input_shape: optional shape tuple, defaults to (None, None, 3).
Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = CSPDarkNetSBackbone()
output = model(input_data)
CSPDarkNetMBackbone
class
keras_cv.models.CSPDarkNetMBackbone(
stackwise_channels,
stackwise_depth,
include_rescaling,
use_depthwise=False,
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
CSPDarkNetBackbone model with [96, 192, 384, 768] channels and [2, 6, 6, 2] depths.
Reference
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Arguments
- include_rescaling: bool, whether or not to rescale the inputs. If set to
True, inputs will be passed through a
Rescaling(1/255.0)
layer. - input_tensor: optional Keras tensor (i.e. output of
layers.Input()
) to use as image input for the model. - input_shape: optional shape tuple, defaults to (None, None, 3).
Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = CSPDarkNetMBackbone()
output = model(input_data)
CSPDarkNetLBackbone
class
keras_cv.models.CSPDarkNetLBackbone(
stackwise_channels,
stackwise_depth,
include_rescaling,
use_depthwise=False,
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
CSPDarkNetBackbone model with [128, 256, 512, 1024] channels and [3, 9, 9, 3] depths.
Reference
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Arguments
- include_rescaling: bool, whether or not to rescale the inputs. If set to
True, inputs will be passed through a
Rescaling(1/255.0)
layer. - input_tensor: optional Keras tensor (i.e. output of
layers.Input()
) to use as image input for the model. - input_shape: optional shape tuple, defaults to (None, None, 3).
Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = CSPDarkNetLBackbone()
output = model(input_data)
CSPDarkNetXLBackbone
class
keras_cv.models.CSPDarkNetXLBackbone(
stackwise_channels,
stackwise_depth,
include_rescaling,
use_depthwise=False,
input_shape=(None, None, 3),
input_tensor=None,
**kwargs
)
CSPDarkNetBackbone model with [170, 340, 680, 1360] channels and [4, 12, 12, 4] depths.
Reference
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Arguments
- include_rescaling: bool, whether or not to rescale the inputs. If set to
True, inputs will be passed through a
Rescaling(1/255.0)
layer. - input_tensor: optional Keras tensor (i.e. output of
layers.Input()
) to use as image input for the model. - input_shape: optional shape tuple, defaults to (None, None, 3).
Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = CSPDarkNetXLBackbone()
output = model(input_data)