--- library_name: keras-hub --- ### Model Overview This class represents the CSPDarkNet architecture. **Reference** - [CSPNet Paper](https://arxiv.org/abs/1911.11929) For transfer learning use cases, make sure to read the [guide to transfer learning & fine-tuning](https://keras.io/guides/transfer_learning/). ## Links * [CSPNet Quickstart Notebook](https://www.kaggle.com/code/prasadsachin/cspnet-quickstart-kerashub) * [CSPDarkNet API Documentation](https://keras.io/keras_hub/api/models/cspnet/) * [CSPDarkNet Model Card](https://huggingface.co/timm/cspdarknet53.ra_in1k) * [KerasHub Beginner Guide](https://keras.io/guides/keras_hub/getting_started/) * [KerasHub Model Publishing Guide](https://keras.io/guides/keras_hub/upload/) ## 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](https://keras.io/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 ```python input_data = np.ones(shape=(8, 224, 224, 3)) # Pretrained backbone model = keras_hub.models.CSPNetBackbone.from_preset("csp_resnet_50_ra_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("csp_resnet_50_ra_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/csp_resnet_50_ra_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/csp_resnet_50_ra_imagenet") #Use Timm presets directly from HuggingFace model = keras_hub.models.ImageClassifier.from_preset('hf://timm/cspdarknet53.ra_in1k') ```