convnextv2 / README.md
Flor's picture
fastforks 0.1.0
5804215
|
Raw History Blame Contribute Delete
5.38 kB
---
library_name: "fastforks"
pipeline_tag: "image-classification"
license: "cc-by-nc-4.0"
tags:
- "classification"
- "image-classification"
- "cuda"
- "pytorch"
- "fastforks"
---
# ConvNeXt V2 (fastforks)
ConvNeXt V2 (Woo et al. 2023): ConvNeXt blocks with global response normalisation, FCMAE pre-training.
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/huggingface/pytorch-image-models> at `0df212b369a5`.
Author weight repos: <https://huggingface.co/timm/convnextv2_base.fcmae_ft_in22k_in1k>.
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`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/classification/models/convnextv2/card.toml).
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
| `convnextv2_base.fcmae_ft_in22k_in1k@1` | [convnextv2_base.fcmae_ft_in22k_in1k.safetensors](https://huggingface.co/timm/convnextv2_base.fcmae_ft_in22k_in1k/resolve/9e250ed8f88b436472d2b24af26f82a8aa8c719d/model.safetensors) | `3b04d2fd7f52` | CC-BY-NC-4.0 | **no** |
## Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Files: .
Training data: ImageNet-21k / ImageNet-22k (full ImageNet, fall 2011 release), ImageNet-1k (ILSVRC 2012 classification).
Licence evidence: <https://huggingface.co/timm/convnextv2_base.fcmae_ft_in22k_in1k/blob/9e250ed8f88b436472d2b24af26f82a8aa8c719d/README.md>
## Input size
fixed 224x224: the input is resized (short side 256) and centre-cropped to it
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `convnextv2_base.fcmae_ft_in22k_in1k` 224x224 (0.3 GiB peak allocated, 0.4 reserved)
## Speed and memory
### Classification, synthetic, 224x224
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `convnextv2_base.fcmae_ft_in22k_in1k` | 10.7 | 14.6 | 10.2 | 2.94 | 3.7x | 3.5x | 542 / 566 | 299 / 376 | 318 / 380 |
### Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- |
| `convnextv2_base.fcmae_ft_in22k_in1k` | 2.70 | 1.23 | 2.12 | 0.63 | 0.03 | 0.16 |
### torch.compile and TensorRT
| model | input | portable ms | compile ms | compile s (cold) | TensorRT fp16 ms | ONNX + build s | kernels ms | peak MiB (alloc / reserved): portable | compile | TensorRT (device) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `convnextv2_base.fcmae_ft_in22k_in1k` | 224x224 | 10.2 | 3.8 | 14.4 | 2.1 | 35 | 2.94 | 299 / 376 | 324 / 356 | 204 |
### Fixed-size speed and peak memory, all models
| model | mode | 224x224 |
| --- | --- | --- |
| `convnextv2_base.fcmae_ft_in22k_in1k` | portable | 10.2 ms / 300 / 370 |
| `convnextv2_base.fcmae_ft_in22k_in1k` | kernels | 3.0 ms / 334 / 450 |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (RTX 5060 Ti 16 GB, sm_120). Original = the authors' code 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
### 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
```python
from fastforks import classification
# non-commercial weights: run with FASTFORKS_NONCOMMERCIAL=1 in the environment
model = classification.load("convnextv2_base.fcmae_ft_in22k_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: `convnextv2_base.fcmae_ft_in22k_in1k`.
## Kernels backend
`classification.load("convnextv2_base.fcmae_ft_in22k_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.
<!-- staged from fastforks feccac41 (2026-11-06) -->