[go: up one dir, main page]

Open source · Python · PyTorch

Faster ports of 573 pretrained vision models from 202 model families

Load a stereo, depth, segmentation, detection or feature model by its id and get the original network's output, faster, within fp16 rounding. Each model is ported to plain PyTorch and checked against the authors' code, then sped up with our own CUDA and Metal kernels.

pip install fastforks
from fastforks import stereo, depth

model = stereo.load("c-foundationstereo-s")
result = model("left.png", "right.png")
result.disparity  # [H, W] float32 tensor, pixels
result.backend    # kernels on CUDA / Apple silicon, else portable

depth.load("depth-anything-v2-s")("room.jpg").inverse_depth
pretrained models
573
model families
202
tasks
20
median vs original
3.3×
best vs original
114.4×
commercially usable
524

Speed-ups: our kernels against the authors' code in its 16-bit precision with the same checkpoint, at each task's standard input, for the 473 models where the original was timed; RTX 5060 Ti 16 GB.

Two modes, measured against the original

Nothing is retrained: fastforks runs the authors' checkpoint. Portable and kernels compute in fp16 by default, so the output is close to the original but not bit-identical; each model page lists how far it is from the authors' code.

  1. original

    The authors' code

    Not part of fastforks, the reference: their repository at a pinned commit with the same checkpoint, run in 16-bit (the authors' own fp16 or bf16 option where the code has one, else torch.autocast fp16). Used to check parity and as the baseline of every speed-up.

  2. portable

    Plain PyTorch

    A clean port with one API. Validated on CPU, NVIDIA CUDA and Apple MPS, so it runs wherever PyTorch runs.

  3. kernels

    Our CUDA & Metal kernels

    The same network with fused kernels: NVIDIA sm_80+ on Linux, and Metal on Apple silicon for most families.

mode="auto" picks kernels where they can run and the measurements prefer them, portable everywhere else. mode="kernels" raises with the reason instead of silently falling back.

Speed

Every row is a median of warm runs, with the accuracy checked on public benchmarks. The RTX 5060 Ti 16 GB is the reference and times the original and both modes; the other devices are surveys of portable against kernels, the Apple M1 Pro across every task. Run fastforks bench MODEL to time both backends on yours.

71 models · input 994x1482 · fastest 8
  1. las2-s 3.0× vs original
    original
    43.5 ms
    portable
    27.8 ms
    kernels
    14.3 ms
  2. las2-m 2.9× vs original
    original
    52.4 ms
    portable
    37.1 ms
    kernels
    18.3 ms
  3. hitnet-eth3d 7.9× vs original
    original
    182 ms
    portable
    67.8 ms
    kernels
    23.2 ms
  4. coex-sceneflow 2.6× vs original
    original
    60.0 ms
    portable
    49.9 ms
    kernels
    23.5 ms
  5. las2-l 3.0× vs original
    original
    90.8 ms
    portable
    75.7 ms
    kernels
    29.9 ms
  6. fast-acvnet-generalization 1.6× vs original +3 checkpoints, same time
    original
    60.6 ms
    portable
    54.7 ms
    kernels
    38.2 ms
  7. fast-acvnet-plus-generalization 1.7× vs original +3 checkpoints, same time
    original
    80.9 ms
    portable
    70.6 ms
    kernels
    46.4 ms
  8. hitnet-middlebury-d400 9.2× vs original
    original
    483 ms
    portable
    176 ms
    kernels
    52.7 ms

RTX 5060 Ti 16 GB (Blackwell, sm_120) · median of warm runs · every release is checked against these times

All 71 stereo matching models in the table →

Tasks

Load by id, call on an image path, array or tensor, get a typed result. Licences, accuracy and memory are on every model page.

Licences

Many vision models are non-commercial. Each fastforks model lists its code licence, weights licence and training data, and is flagged commercial yes only if both licences allow it. Non-commercial weights are never downloaded unless you opt in.

pip install fastforks-core installs only models with permissive code. None of this is legal advice.

import fastforks
from fastforks import stereo

# stereo models whose code and weights allow commercial use
stereo.list_models(commercial="yes")

# licences, and what blocks a "yes"
print(fastforks.describe_models(stereo.list_models("*foundationstereo*")))

Install

fastforks uses the PyTorch you already have. Install PyTorch for your platform first; fastforks uses that build, CUDA or CPU-only. Weights and kernels download on first use and are checked against a recorded SHA-256.

  • Python 3.11+ · PyTorch 2.8+
  • CUDA kernels Linux x86-64 · NVIDIA compute capability 8.0+ (RTX 30, A100 and newer) · driver 570+
  • Metal kernels Apple silicon
  • Portable anywhere PyTorch runs: CPU, CUDA, MPS
pip install fastforks

Everything: all models plus timm, torchvision, transformers and ONNX.

pip install fastforks-core

Lean: models with permissive code, no extra libraries.

# offline machines: fetch ahead of time
fastforks download depth-anything-v2-s --kernels
# which models can run here, and why not
fastforks doctor