KerasHub

Model Overview

This class represents the CSPDarkNet architecture.

Reference

For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.

Links

Installation

Keras and KerasHub can be installed with:

pip install -U -q keras-hub
pip install -U -q keras

Jax, TensorFlow, and Torch come preinstalled in Kaggle Notebooks. For instructions on installing them in another environment see the Keras Getting Started page.

Presets

The following model checkpoints are provided by the Keras team. Weights have been ported from: https://huggingface.co/timm. Full code examples for each are available below.

Preset name Parameters Description
csp_darknet_53_ra_imagenet 27642184 A CSP-DarkNet (Cross-Stage-Partial) image classification model pre-trained on the Randomly Augmented ImageNet 1k dataset at a 256x256 resolution.
csp_resnext_50_ra_imagenet 20569896 A CSP-ResNeXt (Cross-Stage-Partial) image classification model pre-trained on the Randomly Augmented ImageNet 1k dataset at a 256x256 resolution.
csp_resnet_50_ra_imagenet 21616168 A CSP-ResNet (Cross-Stage-Partial) image classification model pre-trained on the Randomly Augmented ImageNet 1k dataset at a 256x256 resolution.
darknet_53_imagenet 41609928 A DarkNet image classification model pre-trained on the Randomly Augmented ImageNet 1k dataset at a 256x256 resolution.

Example Usage

input_data = np.ones(shape=(8, 224, 224, 3))

# Pretrained backbone
model = keras_hub.models.CSPNetBackbone.from_preset("darknet_53_imagenet")
model(input_data)

# Randomly initialized backbone with a custom config
    model = keras_hub.models.CSPNetBackbone(
        stem_filters=32,
        stem_kernel_size=3,
        stem_strides=1,
        stackwise_depth=[1, 2, 4],
        stackwise_strides=[1, 2, 2],
        stackwise_num_filters=[32, 64, 128],
        block_type="dark",
)

model(input_data)

#Use cspnet for image classification task
model = keras_hub.models.ImageClassifier.from_preset("darknet_53_imagenet")

#Use Timm presets directly from HuggingFace
model = keras_hub.models.ImageClassifier.from_preset('hf://timm/cspdarknet53.ra_in1k')

Example Usage with Hugging Face URI

input_data = np.ones(shape=(8, 224, 224, 3))

# Pretrained backbone
model = keras_hub.models.CSPNetBackbone.from_preset("hf://keras/darknet_53_imagenet")
model(input_data)

# Randomly initialized backbone with a custom config
    model = keras_hub.models.CSPNetBackbone(
        stem_filters=32,
        stem_kernel_size=3,
        stem_strides=1,
        stackwise_depth=[1, 2, 4],
        stackwise_strides=[1, 2, 2],
        stackwise_num_filters=[32, 64, 128],
        block_type="dark",
)

model(input_data)

#Use cspnet for image classification task
model = keras_hub.models.ImageClassifier.from_preset("hf://keras/darknet_53_imagenet")

#Use Timm presets directly from HuggingFace
model = keras_hub.models.ImageClassifier.from_preset('hf://timm/cspdarknet53.ra_in1k')
Downloads last month
4
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Collection including keras/darknet_53_imagenet