Resnet18.a1 In1k
A ResNet-B image classification model.
Fonte do modelo
- Tipo
- Other
- Tamanho do arquivo
- 44,6–44,7 MB
- Versão
- vRevision a3dbd14
- Atualizado
- 21 de set. de 2026
- Downloads
- 3
- Fonte
- Hugging Face
Descrição da fonte
Model card for resnet18.a1_in1k
A ResNet-B image classification model.
This model features:
- ReLU activations
- single layer 7x7 convolution with pooling
- 1x1 convolution shortcut downsample
Trained on ImageNet-1k in timm using recipe template described below.
Recipe details:
- ResNet Strikes Back
A1recipe - LAMB optimizer with BCE loss
- Cosine LR schedule with warmup
Model Details
- Model Type: Image classification / feature backbone
- Model Stats:
- Params (M): 11.7
- GMACs: 1.8
- Activations (M): 2.5
- Image size: train = 224 x 224, test = 288 x 288
- Papers:
- ResNet strikes back: An improved training procedure in timm: https://arxiv.org/abs/2110.00476
- Deep Residual Learning for Image Recognition: https://arxiv.org/abs/1512.03385
- Original: https://github.com/huggingface/pytorch-image-models
Model Usage
Image Classification
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('resnet18.a1_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
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(
'resnet18.a1_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, 64, 112, 112])
# torch.Size([1, 64, 56, 56])
# torch.Size([1, 128, 28, 28])
# torch.Size([1, 256, 14, 14])
# torch.Size([1, 512, 7, 7])
print(o.shape)
Image Embeddings
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(
'resnet18.a1_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, 512, 7, 7) shaped tensor
output = model.forward_head(output, pre_logits=True)
# output is a (1, num_features) shaped tensor
Model Comparison
Explore the dataset and runtime metrics of this model in timm model results.
| model | img_size | top1 | top5 | param_count | gmacs | macts | img/sec |
|---|---|---|---|---|---|---|---|
| seresnextaa101d_32x8d.sw_in12k_ft_in1k_288 | 320 | 86.72 | 98.17 | 93.6 | 35.2 | 69.7 | 451 |
| seresnextaa101d_32x8d.sw_in12k_ft_in1k_288 | 288 | 86.51 | 98.08 | 93.6 | 28.5 | 56.4 | 560 |
| seresnextaa101d_32x8d.sw_in12k_ft_in1k | 288 | 86.49 | 98.03 | 93.6 | 28.5 | 56.4 | 557 |
| seresnextaa101d_32x8d.sw_in12k_ft_in1k | 224 | 85.96 | 97.82 | 93.6 | 17.2 | 34.2 | 923 |
| resnext101_32x32d.fb_wsl_ig1b_ft_in1k | 224 | 85.11 | 97.44 | 468.5 | 87.3 | 91.1 | 254 |
| resnetrs420.tf_in1k | 416 | 85.0 | 97.12 | 191.9 | 108.4 | 213.8 | 134 |
| ecaresnet269d.ra2_in1k | 352 | 84.96 | 97.22 | 102.1 | 50.2 | 101.2 | 291 |
| ecaresnet269d.ra2_in1k | 320 | 84.73 | 97.18 | 102.1 | 41.5 | 83.7 | 353 |
| resnetrs350.tf_in1k | 384 | 84.71 | 96.99 | 164.0 | 77.6 | 154.7 | 183 |
| seresnextaa101d_32x8d.ah_in1k | 288 | 84.57 | 97.08 | 93.6 | 28.5 | 56.4 | 557 |
| resnetrs200.tf_in1k | 320 | 84.45 | 97.08 | 93.2 | 31.5 | 67.8 | 446 |
| resnetrs270.tf_in1k | 352 | 84.43 | 96.97 | 129.9 | 51.1 | 105.5 | 280 |
| seresnext101d_32x8d.ah_in1k | 288 | 84.36 | 96.92 | 93.6 | 27.6 | 53.0 | 595 |
| seresnet152d.ra2_in1k | 320 | 84.35 | 97.04 | 66.8 | 24.1 | 47.7 | 610 |
| resnetrs350.tf_in1k | 288 | 84.3 | 96.94 | 164.0 | 43.7 | 87.1 | 333 |
| resnext101_32x8d.fb_swsl_ig1b_ft_in1k | 224 | 84.28 | 97.17 | 88.8 | 16.5 | 31.2 | 1100 |
| resnetrs420.tf_in1k | 320 | 84.24 | 96.86 | 191.9 | 64.2 | 126.6 | 228 |
| seresnext101_32x8d.ah_in1k | 288 | 84.19 | 96.87 | 93.6 | 27.2 | 51.6 | 613 |
| resnext101_32x16d.fb_wsl_ig1b_ft_in1k | 224 | 84.18 | 97.19 | 194.0 | 36.3 | 51.2 | 581 |
| resnetaa101d.sw_in12k_ft_in1k | 288 | 84.11 | 97.11 | 44.6 | 15.1 | 29.0 | 1144 |
| resnet200d.ra2_in1k | 320 | 83.97 | 96.82 | 64.7 | 31.2 | 67.3 | 518 |
| resnetrs200.tf_in1k | 256 | 83.87 | 96.75 | 93.2 | 20.2 | 43.4 | 692 |
| seresnextaa101d_32x8d.ah_in1k | 224 | 83.86 | 96.65 | 93.6 | 17.2 | 34.2 | 923 |
| resnetrs152.tf_in1k | 320 | 83.72 | 96.61 | 86.6 | 24.3 | 48.1 | 617 |
| seresnet152d.ra2_in1k | 256 | 83.69 | 96.78 | 66.8 | 15.4 | 30.6 | 943 |
| seresnext101d_32x8d.ah_in1k | 224 | 83.68 | 96.61 | 93.6 | 16.7 | 32.0 | 986 |
| resnet152d.ra2_in1k | 320 | 83.67 | 96.74 | 60.2 | 24.1 | 47.7 | 706 |
| resnetrs270.tf_in1k | 256 | 83.59 | 96.61 | 129.9 | 27.1 | 55.8 | 526 |
| seresnext101_32x8d.ah_in1k | 224 | 83.58 | 96.4 | 93.6 | 16.5 | 31.2 | 1013 |
| resnetaa101d.sw_in12k_ft_in1k | 224 | 83.54 | 96.83 | 44.6 | 9.1 | 17.6 | 1864 |
| resnet152.a1h_in1k | 288 | 83.46 | 96.54 | 60.2 | 19.1 | 37.3 | 904 |
| resnext101_32x16d.fb_swsl_ig1b_ft_in1k | 224 | 83.35 | 96.85 | 194.0 | 36.3 | 51.2 | 582 |
| resnet200d.ra2_in1k | 256 | 83.23 | 96.53 | 64.7 | 20.0 | 43.1 | 809 |
| resnext101_32x4d.fb_swsl_ig1b_ft_in1k | 224 | 83.22 | 96.75 | 44.2 | 8.0 | 21.2 | 1814 |
| resnext101_64x4d.c1_in1k | 288 | 83.16 | 96.38 | 83.5 | 25.7 | 51.6 | 590 |
| resnet152d.ra2_in1k | 256 | 83.14 | 96.38 | 60.2 | 15.4 | 30.5 | 1096 |
| resnet101d.ra2_in1k | 320 | 83.02 | 96.45 | 44.6 | 16.5 | 34.8 | 992 |
| ecaresnet101d.miil_in1k | 288 | 82.98 | 96.54 | 44.6 | 13.4 | 28.2 | 1077 |
| resnext101_64x4d.tv_in1k | 224 | 82.98 | 96.25 | 83.5 | 15.5 | 31.2 | 989 |
| resnetrs152.tf_in1k | 256 | 82.86 | 96.28 | 86.6 | 15.6 | 30.8 | 951 |
| resnext101_32x8d.tv2_in1k | 224 | 82.83 | 96.22 | 88.8 | 16.5 | 31.2 | 1099 |
| resnet152.a1h_in1k | 224 | 82.8 | 96.13 | 60.2 | 11.6 | 22.6 | 1486 |
| resnet101.a1h_in1k | 288 | 82.8 | 96.32 | 44.6 | 13.0 | 26.8 | 1291 |
| resnet152.a1_in1k | 288 | 82.74 | 95.71 | 60.2 | 19.1 | 37.3 | 905 |
| resnext101_32x8d.fb_wsl_ig1b_ft_in1k | 224 | 82.69 | 96.63 | 88.8 | 16.5 | 31.2 | 1100 |
| resnet152.a2_in1k | 288 | 82.62 | 95.75 | 60.2 | 19.1 | 37.3 | 904 |
| resnetaa50d.sw_in12k_ft_in1k | 288 | 82.61 | 96.49 | 25.6 | 8.9 | 20.6 | 1729 |
| resnet61q.ra2_in1k | 288 | 82.53 | 96.13 | 36.8 | 9.9 | 21.5 | 1773 |
| wide_resnet101_2.tv2_in1k | 224 | 82.5 | 96.02 | 126.9 | 22.8 | 21.2 | 1078 |
| resnext101_64x4d.c1_in1k | 224 | 82.46 | 95.92 | 83.5 | 15.5 | 31.2 | 987 |
| resnet51q.ra2_in1k | 288 | 82.36 | 96.18 | 35.7 | 8.1 | 20.9 | 1964 |
| ecaresnet50t.ra2_in1k | 320 | 82.35 | 96.14 | 25.6 | 8.8 | 24.1 | 1386 |
| resnet101.a1_in1k | 288 | 82.31 | 95.63 | 44.6 | 13.0 | 26.8 | 1291 |
| resnetrs101.tf_in1k | 288 | 82.29 | 96.01 | 63.6 | 13.6 | 28.5 | 1078 |
| resnet152.tv2_in1k | 224 | 82.29 | 96.0 | 60.2 | 11.6 | 22.6 | 1484 |
| wide_resnet50_2.racm_in1k | 288 | 82.27 | 96.06 | 68.9 | 18.9 | 23.8 | 1176 |
| resnet101d.ra2_in1k | 256 | 82.26 | 96.07 | 44.6 | 10.6 | 22.2 | 1542 |
| resnet101.a2_in1k | 288 | 82.24 | 95.73 | 44.6 | 13.0 | 26.8 | 1290 |
| seresnext50_32x4d.racm_in1k | 288 | 82.2 | 96.14 | 27.6 | 7.0 | 23.8 | 1547 |
Fontes
1 fonte
Fontes
1 fonteVerificado 10 de set.
Artefatos de modelo
2 artefatos
Artefatos de modelo
2 artefatosTrechos de fonte
2 trechos
Trechos de fonte
2 trechos--- tags: - image-classification - timm - transformers license: apache-2.0 library_name: timm --- # Model card for resnet18.a1_in1k A ResNet-B image classification model. This model features: * ReLU activations * single layer 7x7 convolution with pooling * 1x1 convolution shortcut downsample Trained on ImageNet-1k in `timm` using recipe template described below. Recipe details: * ResNet Strikes Back `A1` recipe * LAMB optimizer with BCE loss * Cosine LR schedule with warmup ## Model Details - **Model Type:** Image classification / feature backbone - **Model Stats:** - Params (M): 11.7 - GMACs: 1.8 - Activations (M): 2.5 - Image size: train = 224 x 224, test = 288 x 288 - **Papers:** - ResNet strikes back: An improved training procedure in timm: https://arxiv.org/abs/2110.00476 - Deep Residual Learning for Image Recognition: https://arxiv.org/abs/1512.03385 - **Original:** https://github.com/huggingface/pytorch-image-models ## 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('resnet18.a1_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( 'resnet18.a1_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, 64, 112, 112]) # t...
Source context: 3 downloads · 0 likes · Pipeline image-classification · Library timm · Repo user2103283101/resnet18.a1_in1k
