ResNet (fastforks)

ResNet (He et al. 2015): residual basic / bottleneck blocks.

This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/pytorch/vision at 1f1a920d685d.

Task: classification. Tier: stable. Outputs: logits. Backends: portable, kernels.

Input: one RGB image. Output: ImageNet-1k class logits.

Variants

Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.

variant weights (author link) SHA-256 weights licence commercial use
resnet152.tv2_in1k@1 resnet152-f82ba261.pth f82ba2614b9f BSD-3-Clause (assumed from code) yes
resnet18.tv_in1k@1 resnet18-f37072fd.pth f37072fd47e8 BSD-3-Clause (assumed from code) yes
resnet50.tv2_in1k@1 resnet50-11ad3fa6.pth 11ad3fa62ca7 BSD-3-Clause (assumed from code) yes

Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: BSD-3-Clause.

Code licence: BSD-3-Clause; the authors do not state a separate weights licence.

Training data: ImageNet-1k (ILSVRC 2012 classification).

Licence evidence: https://github.com/pytorch/vision/blob/1f1a920d685d46dfbe187934b785b7ecb7a182f2/LICENSE

Input size

  • resnet152.tv2_in1k, resnet50.tv2_in1k: fixed 224x224: the input is resized (short side 232) and centre-cropped to it
  • resnet18.tv_in1k: fixed 224x224: the input is resized (short side 256) and centre-cropped to it Tested up to (portable, fp16, RTX 5060 Ti 16 GB): resnet152.tv2_in1k 224x224 (0.2 GiB peak allocated, 0.2 reserved); resnet18.tv_in1k 224x224 (0.1 GiB peak allocated, 0.1 reserved); resnet50.tv2_in1k 224x224 (0.1 GiB peak allocated, 0.1 reserved)

Speed and memory

Classification, synthetic

model input time (ms): original fp32 original portable kernels kernels speed-up: vs original vs portable peak memory (MiB, allocated / reserved): original portable kernels
resnet152.tv2_in1k 224x224 12.8 16.3 8.36 1.83 7.0x 4.6x 378 / 390 155 / 186 182 / 266
resnet18.tv_in1k 224x224 1.91 2.44 1.48 0.459 4.2x 3.2x 105 / 130 61 / 90 90 / 150
resnet50.tv2_in1k 224x224 4.74 5.84 3.15 0.826 5.7x 3.8x 180 / 192 89 / 142 116 / 162

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
resnet152.tv2_in1k 2.34 0.43 1.88 0.24 0.02 0.04
resnet18.tv_in1k 0.27 0.07 1.48 0.00 0.00 0.04
resnet50.tv2_in1k 0.51 0.16 1.48 0.01 0.00 0.04

torch.compile and TensorRT

model input time: portable compile TensorRT fp16 kernels preparation: compile (cold first call) ONNX + engine build peak MiB (alloc / reserved): portable compile kernels TensorRT (engine + torch)
resnet152.tv2_in1k 224x224 8.36 ms 4.55 ms 1.09 ms 1.83 ms 8.82 s 22.7 s 155 / 186 185 / 240 182 / 266 282 / 334
resnet18.tv_in1k 224x224 1.48 ms 1.04 ms 0.220 ms 0.459 ms 4.31 s 14.0 s 61 / 90 91 / 108 90 / 150 89 / 120
resnet50.tv2_in1k 224x224 3.15 ms 2.10 ms 0.466 ms 0.826 ms 8.31 s 24.0 s 89 / 142 119 / 138 116 / 162 152 / 166

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.

Accuracy

On public datasets

fastforks: the model's own resize / crop on the GPU; original: the library's pretrained loader and its PIL eval transform. Original = the original code named under Details, same checkpoint and protocol.

variant dataset original fp32 original fp16 portable kernels note
resnet18.tv_in1k ImageNet-1k val, 5000 random images, top-1 / top-5 % 70.80 / 89.18 70.80 / 89.18 70.82 / 89.12 70.74 / 89.10
resnet50.tv2_in1k ImageNet-1k val, 5000 random images, top-1 / top-5 % 82.02 / 95.32 82.00 / 95.30 81.94 / 95.30 81.96 / 95.34
resnet152.tv2_in1k ImageNet-1k val, 5000 random images, top-1 / top-5 % 82.90 / 96.22 82.90 / 96.20 82.90 / 96.24 82.90 / 96.24

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Parity with the original code

Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.02 and p99 <= 0.08 (absolute error of the output logits).

Usage

from fastforks import classification

model = classification.load("resnet152.tv2_in1k")  # mode="auto": the preferred backend from recorded measurements
result = model("photo.jpg")
result.top(5)  # top-5 classes
result.backend  # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')

Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: resnet152.tv2_in1k, resnet18.tv_in1k, resnet50.tv2_in1k.

Kernels backend

classification.load("resnet152.tv2_in1k", mode="kernels") runs our CUDA kernels (cudnn_hacc, fvm_conv, fvm_extra, fvm_mb, fvm_r3). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Collection including fastforks/resnet