resnet50.ram in1k

Providertimm
Categoryimage-classification
Licenseapache-2.0
Downloads1.8K
Stars0

Overview

ResNet-50 (ImageNet-1K) is a foundational convolutional neural network (CNN) that remains a primary baseline for computer vision tasks. By utilizing residual learning to mitigate the vanishing gradient problem, it allows for deeper architectures without sacrificing convergence. For developers, this model is highly efficient for image classification, feature extraction, and as a backbone for more complex architectures like Mask R-CNN or Faster R-CNN. Integration is seamless via the timm library, providing a standardized interface for loading weights and fine-tuning on custom datasets. While newer transformers offer higher peak accuracy, ResNet-50 is often preferred in production environments due to its predictable latency, lower computational overhead, and extensive community support.

Highlights

  • Industry-standard backbone for transfer learning and feature extraction
  • Optimized for low-latency inference across diverse hardware
  • Easy integration via the timm library ecosystem
  • Proven stability for image classification and object detection
  • Apache-2.0 license ensures flexible commercial deployment

Usage

Install
# Install Hugging Face transformers
pip install transformers torch
SDK Usage
# Load model with transformers
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("timm/resnet50.ram_in1k")
tokenizer = AutoTokenizer.from_pretrained("timm/resnet50.ram_in1k")

Hugging Face Download

We recommend downloading the model via the Hugging Face CLI or Hub SDK.

Guidance:Before downloading, install huggingface_hub with:

Guidance
pip install -U huggingface_hub

CLI Download

Download the full repository

Download the full repository
huggingface-cli download timm/resnet50.ram_in1k

Download a single file to a local folder (e.g. config.json into ./dir)

Download a single file to a local folder (e.g. config.json into ./dir)
huggingface-cli download timm/resnet50.ram_in1k config.json --local-dir ./dir

See the official docs for more CLI options

SDK Download

SDK Download
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('timm/resnet50.ram_in1k')

Git Download

Make sure git-lfs is installed first

Git Download
git lfs install
git clone https://huggingface.co/timm/resnet50.ram_in1k

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/timm/resnet50.ram_in1k

Model files are hosted on the Hugging Face Hub — download directly via HF CLI / SDK / Git, not through this site.

PyTorch / Transformers Usage

Install Transformers

Install Transformers
pip install -U transformers torch

Load the model and run inference

Load the model and run inference
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('timm/resnet50.ram_in1k')
tokenizer = AutoTokenizer.from_pretrained('timm/resnet50.ram_in1k')

Model Download

We recommend downloading the model via the ModelScope CLI or SDK.

Guidance:Before downloading, install ModelScope with:

Guidance
pip install modelscope

CLI Download

Download the full repository

Download the full repository
modelscope download --model timm/resnet50.ram_in1k

Download a single file to a local folder (e.g. README.md into ./dir)

Download a single file to a local folder (e.g. README.md into ./dir)
modelscope download --model timm/resnet50.ram_in1k README.md --local_dir ./dir

See the docs for more CLI options

SDK Download

SDK Download
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('timm/resnet50.ram_in1k')

Git Download

Make sure git-lfs is installed first

Git Download
git lfs install
git clone https://www.modelscope.cn/timm/resnet50.ram_in1k.git

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/timm/resnet50.ram_in1k.git

ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。

Notebook Quickstart

Install the ModelScope library

Install the ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

Load the model and run inference

Load the model and run inference
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

p = pipeline('text-generation', 'timm/resnet50.ram_in1k')

Full Documentation

来源: HuggingFace

---
license: apache-2.0
library_name: timm
tags:

  • image-classification

  • timm

  • transformers

---

Model card for resnet50.ram_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:
* AugMix (with RandAugment) recipe
* SGD (w/ Nesterov) optimizer and JSD (Jensen–Shannon divergence) loss
* Cosine LR schedule with warmup

Model Details

  • Model Type: Image classification / feature backbone
  • Model Stats:
- Params (M): 25.6 - GMACs: 4.1 - Activations (M): 11.1 - Image size: train = 224 x 224, test = 288 x 288
  • Papers:
- 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('resnet50.ram_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(
'resnet50.ram_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, 256, 56, 56])
# torch.Size([1, 512, 28, 28])
# torch.Size([1, 1024, 14, 14])
# torch.Size([1, 2048, 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(
'resnet50.ram_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, 2048, 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](https://huggingface.co/timm/resnet

Join our Telegram