CoolFace
Modelpublic

timm/hgnet_tiny.paddle_in1k

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes98downloads
Model Card

Model card for hgnettiny.paddlein1k

A HGNet (High Performance GPU Net) image classification model. Trained on ImageNet-1k by model authors.

Model Details

  • Model Type: Image classification / feature backbone
  • Model Stats:
  • Params (M): 14.7
  • GMACs: 4.5
  • Activations (M): 6.4
  • Image size: train = 224 x 224, test = 288 x 288
  • Dataset: ImageNet-1k
  • Papers:
  • Model paper unknown: TBD
  • Beyond Self-Supervision: A Simple Yet Effective Network Distillation Alternative to Improve Backbones: https://arxiv.org/abs/2103.05959
  • Original: https://github.com/PaddlePaddle/PaddleClas

Model Usage

Image Classification

python
from urllib.request import urlopen
from PIL import Image
import timm

img = Image.open(urlopen(
    'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
))

model = timm.create_model('hgnet_tiny.paddle_in1k', pretrained=True)
model = model.eval()

# get model specific transforms (normalization, resize)
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)

output = model(transforms(img).unsqueeze(0))  # unsqueeze single image into batch of 1

top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)

Feature Map Extraction

python
from urllib.request import urlopen
from PIL import Image
import timm

img = Image.open(urlopen(
    'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
))

model = timm.create_model(
    'hgnet_tiny.paddle_in1k',
    pretrained=True,
    features_only=True,
)
model = model.eval()

# get model specific transforms (normalization, resize)
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)

output = model(transforms(img).unsqueeze(0))  # unsqueeze single image into batch of 1

for o in output:
    # print shape of each feature map in output
    # e.g.:
    #  torch.Size([1, 224, 56, 56])
    #  torch.Size([1, 448, 28, 28])
    #  torch.Size([1, 512, 14, 14])
    #  torch.Size([1, 768, 7, 7])

    print(o.shape)

Image Embeddings

python
from urllib.request import urlopen
from PIL import Image
import timm

img = Image.open(urlopen(
    'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
))

model = timm.create_model(
    'hgnet_tiny.paddle_in1k',
    pretrained=True,
    num_classes=0,  # remove classifier nn.Linear
)
model = model.eval()

# get model specific transforms (normalization, resize)
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)

output = model(transforms(img).unsqueeze(0))  # output is (batch_size, num_features) shaped tensor

# or equivalently (without needing to set num_classes=0)

output = model.forward_features(transforms(img).unsqueeze(0))
# output is unpooled, a (1, 768, 7, 7) shaped tensor

output = model.forward_head(output, pre_logits=True)
# output is a (1, num_features) shaped tensor

Model Comparison

By Top-1

modeltop1top1_errtop5top5_errparam_countimg_size
hgnetv2b6.ssldstage2ftin1k86.3613.6497.9342.06675.26288
hgnetv2b6.ssldstage1in22kin1k86.29413.70697.9482.05275.26288
hgnetv2b6.ssldstage2ftin1k86.20413.79697.812.1975.26224
hgnetv2b6.ssldstage1in22kin1k86.02813.97297.8042.19675.26224
hgnetbase.ssldin1k85.47414.52697.6322.36871.58288
hgnetv2b5.ssldstage2ftin1k85.14614.85497.6122.38839.57288
hgnetv2b5.ssldstage1in22kin1k84.92815.07297.5142.48639.57288
hgnetbase.ssldin1k84.91215.08897.3422.65871.58224
hgnetv2b5.ssldstage2ftin1k84.80815.19297.32.739.57224
hgnetv2b5.ssldstage1in22kin1k84.45815.54297.222.7839.57224
hgnetsmall.ssldin1k84.37615.62497.1282.87224.36288
hgnetv2b4.ssldstage2ftin1k83.91216.08897.062.9419.8288
hgnetsmall.ssldin1k83.80816.19296.8483.15224.36224
hgnetv2b4.ssldstage2ftin1k83.69416.30696.7863.21419.8224
hgnetv2b3.ssldstage2ftin1k83.5816.4296.813.1916.29288
hgnetv2b4.ssldstage1in22kin1k83.4516.5596.923.0819.8288
hgnetv2b3.ssldstage1in22kin1k83.11616.88496.7123.28816.29288
hgnetv2b3.ssldstage2ftin1k82.91617.08496.3643.63616.29224
hgnetv2b4.ssldstage1in22kin1k82.89217.10896.6323.36819.8224
hgnetv2b3.ssldstage1in22kin1k82.58817.41296.383.6216.29224
hgnettiny.ssldin1k82.52417.47696.5143.48614.74288
hgnetv2b2.ssldstage2ftin1k82.34617.65496.3943.60611.22288
hgnetsmall.paddlein1k82.22217.77896.223.7824.36288
hgnettiny.ssldin1k81.93818.06296.1143.88614.74224
hgnetv2b2.ssldstage2ftin1k81.57818.42295.8964.10411.22224
hgnetv2b2.ssldstage1in22kin1k81.4618.5496.013.9911.22288
hgnetsmall.paddlein1k81.35818.64295.8324.16824.36224
hgnetv2b2.ssldstage1in22kin1k80.7519.2595.4984.50211.22224
hgnettiny.paddlein1k80.6419.3695.544.4614.74288
hgnetv2b1.ssldstage2ftin1k79.90420.09695.1484.8526.34288
hgnettiny.paddlein1k79.89420.10695.0524.94814.74224
hgnetv2b1.ssldstage1in22kin1k79.04820.95294.8825.1186.34288
hgnetv2b1.ssldstage2ftin1k78.87221.12894.4925.5086.34224
hgnetv2b0.ssldstage2ftin1k78.58621.41494.3885.6126.0288
hgnetv2b1.ssldstage1in22kin1k78.0521.9594.1825.8186.34224
hgnetv2b0.ssldstage1in22kin1k78.02621.97494.2425.7586.0288
hgnetv2b0.ssldstage2ftin1k77.34222.65893.7866.2146.0224
hgnetv2b0.ssldstage1in22kin1k76.84423.15693.6126.3886.0224

Citation

bibtex
@article{cui2021beyond,
  title={Beyond Self-Supervision: A Simple Yet Effective Network Distillation Alternative to Improve Backbones},
  author={Cui, Cheng and Guo, Ruoyu and Du, Yuning and He, Dongliang and Li, Fu and Wu, Zewu and Liu, Qiwen and Wen, Shilei and Huang, Jizhou and Hu, Xiaoguang and others},
  journal={arXiv preprint arXiv:2103.05959},
  year={2021}
}