CoolFace
Modelpublic

keras/darknet_53_imagenet

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes5downloads
Model Card

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 nameParametersDescription
csp_darknet_53_ra_imagenet27642184A 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_imagenet20569896A 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_imagenet21616168A CSP-ResNet (Cross-Stage-Partial) image classification model pre-trained on the Randomly Augmented ImageNet 1k dataset at a 256x256 resolution.
darknet_53_imagenet41609928A DarkNet image classification model pre-trained on the Randomly Augmented ImageNet 1k dataset at a 256x256 resolution.

Example Usage

python
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

python
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')