timm documentation

GhostNet

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

GhostNet

Category: Efficient/Mobile · Code: timm/models/ghostnet.py · Architectures: 10 · Pretrained weights: 5 (5 with ImageNet-1k results)

GhostNet generates part of its feature maps with cheap operations (Ghost modules). GhostNetV2 adds DFC attention for long-range dependencies, GhostNetV3 uses re-parameterization and knowledge distillation in training.

Papers

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('ghostnetv2_160.in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)

Model API support

FeatureGhostNet
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 (GhostNet with ghostnet_050 at 224), other architectures of the same class are expected to behave the same. See the Model API page for details.

Architectures

ArchitectureParams (M)GMACsInput sizePretrained weights
ghostnet_0502.590.052240
ghostnet_1005.180.152241
ghostnet_1307.360.242240
ghostnetv2_1006.160.182241
ghostnetv2_1308.960.282241
ghostnetv2_16012.390.422241
ghostnetv3_0502.850.052240
ghostnetv3_1006.150.172241
ghostnetv3_1308.950.282240
ghostnetv3_16012.380.412240

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.

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
ghostnet_100.in1k22473.9582241000apache-2.0timm
ghostnetv2_100.in1k22475.1862241000apache-2.0timm
ghostnetv2_130.in1k22476.7462241000apache-2.0timm
ghostnetv2_160.in1k22477.8362241000apache-2.0timm
ghostnetv3_100.in1k22476.9362241000apache-2.0timm
Update on GitHub