opensi·si

timm/models/cspnet.py ·

CSPNet (CSPResNet, CSPDarkNet, DarkNet)

Category: CNN · Code: timm/models/cspnet.py · Architectures: 23 · Pretrained weights: 15 (15 with ImageNet-1k results)

Cross Stage Partial Networks split the features of each stage into two parts, one passing through the stage blocks and one merged back at the end of the stage. This module holds CSPResNet, CSPResNeXt, CSPDarkNet, DarkNet and the timm cs3* variants.

Papers

  • CSPNet: A New Backbone that can Enhance Learning Capability of CNN
  • YOLOv3: An Incremental Improvement

Usage

See the Quickstart for loading pretrained weights, image preprocessing and fine-tuning, and Feature Extraction for using the models as backbones.

>>> import timm
>>> model = timm.create_model('cspdarknet53.ra_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)

Model API support

Feature CspNet
features_only=True feature maps ✓ (strides 2, 4, 8, 16, 32)
forward_intermediates() ✓
prune_intermediate_layers() ✓
Any input size, no changes needed ✓
set_input_size() –
dynamic_img_size=True –
set_grad_checkpointing() ✗
Layer-wise LR decay (group_matcher()) ✓
reset_classifier() ✓

✓ supported, ✓ (square) works for square sizes only, ✗ not supported, – not needed (the model already accepts any input size). Checked by running each feature on a randomly initialized model (CspNet with cs3darknet_focus_s at 256), other architectures of the same class are expected to behave the same. See the Model API page for details.

Architectures

表格(24 行)
Architecture Params (M) GMACs Input size Pretrained weights
cs3darknet_focus_l 21.15 4.66 256 1
cs3darknet_focus_m 9.30 1.98 256 1
cs3darknet_focus_s 3.27 0.69 256 1
cs3darknet_focus_x 35.02 8.03 256 0
cs3darknet_l 21.16 4.86 256 1
cs3darknet_m 9.31 2.08 256 1
cs3darknet_s 3.28 0.72 256 0
cs3darknet_x 35.05 8.38 256 1
cs3edgenet_x 47.82 11.53 256 1
cs3se_edgenet_x 50.72 11.53 256 1
cs3sedarknet_l 21.91 4.86 256 1
cs3sedarknet_x 35.40 8.38 256 1
cs3sedarknet_xdw 21.60 5.97 256 0
cspdarknet53 27.64 6.57 256 1
cspresnet50 21.62 4.54 256 1
cspresnet50d 21.64 4.86 256 0
cspresnet50w 28.12 5.04 256 0
cspresnext50 20.57 4.05 256 1
darknet17 14.30 3.26 256 0
darknet21 20.86 3.93 256 0
darknet53 41.61 9.31 256 1
darknetaa53 36.02 7.97 256 1
sedarknet21 20.95 3.93 256 0

GMACs and parameter counts are for the default input size and classifier of each architecture, from the benchmark results.

Pretrained weights

Top-1 is ImageNet-1k validation accuracy from results-imagenet.csv at the listed eval size, - if the weight has no ImageNet-1k result (e.g. pretraining or image-text weights). Classes is the size of the pretrained classifier, none for weights without one.

Weights are grouped by source: the paper or origin given in the pretrained config, else a Hub organization other than timm, else the first part of the pretrained tag (architecture.tag). Sources with a single weight are listed under other.

c2ns tags

Weight Input size Top-1 (%) Eval size Classes License Hub
cs3darknet_focus_l.c2ns_in1k 256 (test 288) 80.894 288 1000 apache-2.0 timm
cs3darknet_focus_m.c2ns_in1k 256 (test 288) 77.286 288 1000 apache-2.0 timm
cs3darknet_l.c2ns_in1k 256 (test 288) 80.882 288 1000 apache-2.0 timm
cs3darknet_m.c2ns_in1k 256 (test 288) 77.636 288 1000 apache-2.0 timm
cs3darknet_x.c2ns_in1k 256 (test 288) 82.234 288 1000 apache-2.0 timm
cs3se_edgenet_x.c2ns_in1k 256 (test 320) 83.550 320 1000 apache-2.0 timm
cs3sedarknet_l.c2ns_in1k 256 (test 288) 81.770 288 1000 apache-2.0 timm
cs3sedarknet_x.c2ns_in1k 256 (test 288) 82.654 288 1000 apache-2.0 timm
darknet53.c2ns_in1k 256 (test 288) 80.542 288 1000 apache-2.0 timm
darknetaa53.c2ns_in1k 256 (test 288) 80.528 288 1000 apache-2.0 timm

ra tags

Weight Input size Top-1 (%) Eval size Classes License Hub
cspdarknet53.ra_in1k 256 80.078 256 1000 apache-2.0 timm
cspresnet50.ra_in1k 256 79.578 256 1000 apache-2.0 timm
cspresnext50.ra_in1k 256 80.548 256 1000 apache-2.0 timm

Other

Weight Input size Top-1 (%) Eval size Classes License Hub
cs3darknet_focus_s.ra4_e3600_r256_in1k 256 (test 320) 73.158 320 1000 apache-2.0 timm
cs3edgenet_x.c2_in1k 256 (test 288) 82.734 288 1000 apache-2.0 timm

Source and license

Source: timm documentation, adapted for this site. Licensing and attribution follow the terms of the upstream project.