# PP-HGNet

**Category:** CNN · **Code:**
[`timm/models/hgnet.py`](https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/hgnet.py) ·
**Architectures:** 10 · **Pretrained weights:** 19 (19 with ImageNet-1k results)

PP-HGNet and PP-HGNetV2 (High Performance GPU Net) from PaddleClas, built from HG blocks that aggregate the outputs of a
sequence of convolutions. The `ssld` weights are trained with PaddleClas SSLD distillation.

## Papers

* [Beyond Self-Supervision: A Simple Yet Effective Network Distillation Alternative to Improve
  Backbones](https://arxiv.org/abs/2103.05959)

## Usage

See the [Quickstart](../quickstart) for loading pretrained weights, image preprocessing and fine-tuning, and [Feature
Extraction](../feature_extraction) for using the models as backbones.

```py
>>> import timm
>>> model = timm.create_model('hgnet_small.paddle_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)
```

## Model API support

| Feature | `HighPerfGpuNet` |
|---|---|
| [`features_only=True` feature maps](../model_api#intermediate-features) | ✓ (strides 4, 8, 16, 32) |
| [`forward_intermediates()`](../model_api#intermediate-features) | ✓ |
| [`prune_intermediate_layers()`](../model_api#intermediate-features) | ✓ |
| [Any input size, no changes needed](../model_api#input-size) | ✓ |
| [`set_input_size()`](../model_api#input-size) | – |
| [`dynamic_img_size=True`](../model_api#input-size) | – |
| [`set_grad_checkpointing()`](../model_api#training-hooks) | ✓ |
| [Layer-wise LR decay (`group_matcher()`)](../model_api#training-hooks) | ✓ |
| [`reset_classifier()`](../model_api#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 (`HighPerfGpuNet` with `hgnetv2_b0` at 224),
other architectures of the same class are expected to behave the same. See the [Model API](../model_api) page for
details.

## Architectures

| Architecture | Params (M) | GMACs | Input size | Pretrained weights |
|---|---:|---:|---:|---:|
| `hgnet_base` | 71.58 | 25.14 | 224 | 1 |
| `hgnet_small` | 24.36 | 8.53 | 224 | 2 |
| `hgnet_tiny` | 14.74 | 4.54 | 224 | 2 |
| `hgnetv2_b0` | 6.00 | 0.33 | 224 | 2 |
| `hgnetv2_b1` | 6.34 | 0.49 | 224 | 2 |
| `hgnetv2_b2` | 11.22 | 1.15 | 224 | 2 |
| `hgnetv2_b3` | 16.29 | 1.78 | 224 | 2 |
| `hgnetv2_b4` | 19.80 | 2.75 | 224 | 2 |
| `hgnetv2_b5` | 39.57 | 6.56 | 224 | 2 |
| `hgnetv2_b6` | 75.26 | 16.88 | 224 | 2 |

GMACs and parameter counts are for the default input size and classifier of each architecture, from the [benchmark
results](https://github.com/huggingface/pytorch-image-models/tree/main/results).

## Pretrained weights

Top-1 is ImageNet-1k validation accuracy from
[`results-imagenet.csv`](https://github.com/huggingface/pytorch-image-models/blob/main/results/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.

### `ssld` tags

| Weight | Input size | Top-1 (%) | Eval size | Classes | License | Hub |
|---|---:|---:|---:|---:|---|---|
| `hgnet_base.ssld_in1k` | 224 (test 288) | 85.488 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnet_base.ssld_in1k) |
| `hgnet_small.ssld_in1k` | 224 (test 288) | 84.368 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnet_small.ssld_in1k) |
| `hgnet_tiny.ssld_in1k` | 224 (test 288) | 82.528 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnet_tiny.ssld_in1k) |
| `hgnetv2_b0.ssld_stage1_in22k_in1k` | 224 (test 288) | 78.038 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b0.ssld_stage1_in22k_in1k) |
| `hgnetv2_b0.ssld_stage2_ft_in1k` | 224 (test 288) | 78.590 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b0.ssld_stage2_ft_in1k) |
| `hgnetv2_b1.ssld_stage1_in22k_in1k` | 224 (test 288) | 79.050 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b1.ssld_stage1_in22k_in1k) |
| `hgnetv2_b1.ssld_stage2_ft_in1k` | 224 (test 288) | 79.916 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b1.ssld_stage2_ft_in1k) |
| `hgnetv2_b2.ssld_stage1_in22k_in1k` | 224 (test 288) | 81.456 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b2.ssld_stage1_in22k_in1k) |
| `hgnetv2_b2.ssld_stage2_ft_in1k` | 224 (test 288) | 82.362 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b2.ssld_stage2_ft_in1k) |
| `hgnetv2_b3.ssld_stage1_in22k_in1k` | 224 (test 288) | 83.118 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b3.ssld_stage1_in22k_in1k) |
| `hgnetv2_b3.ssld_stage2_ft_in1k` | 224 (test 288) | 83.588 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b3.ssld_stage2_ft_in1k) |
| `hgnetv2_b4.ssld_stage1_in22k_in1k` | 224 (test 288) | 83.450 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b4.ssld_stage1_in22k_in1k) |
| `hgnetv2_b4.ssld_stage2_ft_in1k` | 224 (test 288) | 83.952 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b4.ssld_stage2_ft_in1k) |
| `hgnetv2_b5.ssld_stage1_in22k_in1k` | 224 (test 288) | 84.930 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b5.ssld_stage1_in22k_in1k) |
| `hgnetv2_b5.ssld_stage2_ft_in1k` | 224 (test 288) | 85.158 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b5.ssld_stage2_ft_in1k) |
| `hgnetv2_b6.ssld_stage1_in22k_in1k` | 224 (test 288) | 86.300 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b6.ssld_stage1_in22k_in1k) |
| `hgnetv2_b6.ssld_stage2_ft_in1k` | 224 (test 288) | 86.380 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnetv2_b6.ssld_stage2_ft_in1k) |

### `paddle` tags

| Weight | Input size | Top-1 (%) | Eval size | Classes | License | Hub |
|---|---:|---:|---:|---:|---|---|
| `hgnet_small.paddle_in1k` | 224 (test 288) | 82.222 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnet_small.paddle_in1k) |
| `hgnet_tiny.paddle_in1k` | 224 (test 288) | 80.644 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/hgnet_tiny.paddle_in1k) |

