|
Download README.md from fastforks/raft: direct link, hf CLI and curl.
- Browser
- Download file 11 kB
-
https://huggingface.co/fastforks/raft/resolve/main/README.md
- Command line
-
hf download hf://fastforks/raft/README.md
-
curl -L -o README.md https://huggingface.co/fastforks/raft/resolve/main/README.md
11 kB
| library_name: "fastforks" | |
| pipeline_tag: "image-to-image" | |
| license: "other" | |
| license_name: "see-model-card" | |
| license_link: "https://github.com/pytorch/vision/blob/1f1a920d685d46dfbe187934b785b7ecb7a182f2/torchvision/models/optical_flow/raft.py#L576" | |
| tags: | |
| - "flow" | |
| - "optical-flow" | |
| - "motion-estimation" | |
| - "cuda" | |
| - "pytorch" | |
| - "fastforks" | |
| - "fastforks-card" | |
| # RAFT (fastforks) | |
| RAFT (Teed & Deng 2020): all-pairs correlation pyramid at 1/8 resolution and a ConvGRU that refines the flow in 12 iterations, upsampled with a learned convex mask (raft-small: bilinear). torchvision's V2 weights (trained from scratch with its optical-flow reference recipe); the network is ported from torchvision (no torchvision dependency). | |
| 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: flow. Tier: stable. Outputs: `flow`. Backends: `portable`, `kernels`. | |
| Input: two RGB images (consecutive frames). Output: per-pixel motion from the first to the second (dx, dy in pixels). | |
| ## 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/flow/models/raft/card.toml). | |
| | variant | weights (author link) | SHA-256 | weights licence | commercial use | | |
| |---|---|---|---|---| | |
| | `raft-large@1` | [raft_large_C_T_SKHT_V2-ff5fadd5.pth](https://download.pytorch.org/models/raft_large_C_T_SKHT_V2-ff5fadd5.pth) | `ff5fadd56d26` | BSD-3-Clause (assumed from code) | yes | | |
| | `raft-large-kitti@1` | [raft_large_C_T_SKHT_K_V2-b5c70766.pth](https://download.pytorch.org/models/raft_large_C_T_SKHT_K_V2-b5c70766.pth) | `b5c7076664d2` | BSD-3-Clause (assumed from code) | yes | | |
| | `raft-large-things@1` | [raft_large_C_T_V2-1bb1363a.pth](https://download.pytorch.org/models/raft_large_C_T_V2-1bb1363a.pth) | `1bb1363a43b4` | BSD-3-Clause (assumed from code) | yes | | |
| | `raft-small@1` | [raft_small_C_T_V2-01064c6d.pth](https://download.pytorch.org/models/raft_small_C_T_V2-01064c6d.pth) | `01064c6dba73` | 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. Licence files: `LICENSE`. | |
| Code licence: BSD-3-Clause; the authors do not state a separate weights licence. | |
| Training data: FlyingChairs (Freiburg), Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa) (FlyingChairs, then FlyingThings3D (part of SceneFlow)). | |
| Licence evidence: <https://github.com/pytorch/vision/blob/1f1a920d685d46dfbe187934b785b7ecb7a182f2/torchvision/models/optical_flow/raft.py#L576> | |
| ## Input size | |
| any H x W >= 128, padded to a multiple of 8 | |
| Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `raft-large` 1024x2048 (8.3 GiB peak allocated, 9.0 reserved); `raft-large-kitti` 1024x2048 (8.3 GiB peak allocated, 9.0 reserved); `raft-large-things` 1024x2048 (8.3 GiB peak allocated, 9.0 reserved); `raft-small` 1024x2048 (8.2 GiB peak allocated, 8.7 reserved) | |
| ## Speed and memory | |
| ### Flow, synthetic, 1080x1920 | |
| | model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels | | |
| | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | |
| | `raft-large` | 480 | 567 | 283 | 83.4 | 5.7x | 3.4x | 7164 / 10928 | 5721 / 5758 | 332 / 352 | | |
| | `raft-large-kitti` | 480 | 567 | 284 | 84.2 | 5.7x | 3.4x | 7164 / 10928 | 5721 / 5758 | 332 / 352 | | |
| | `raft-large-things` | 481 | 566 | 283 | 83.5 | 5.8x | 3.4x | 7164 / 10928 | 5721 / 5758 | 332 / 352 | | |
| | `raft-small` | 196 | 395 | 141 | 36.5 | 5.4x | 3.9x | 7032 / 10888 | 5601 / 5646 | 196 / 204 | | |
| ### Startup and first call | |
| | model | load (s): original | portable | kernels | first call (s): original | portable | kernels | | |
| | --- | --- | --- | --- | --- | --- | --- | | |
| | `raft-large` | 0.14 | 0.17 | 1.07 | 0.76 | 0.30 | 0.11 | | |
| | `raft-large-kitti` | 0.14 | 0.17 | 1.06 | 0.58 | 0.30 | 0.11 | | |
| | `raft-large-things` | 0.13 | 0.25 | 1.07 | 0.58 | 0.30 | 0.11 | | |
| | `raft-small` | 0.09 | 0.16 | 1.06 | 0.43 | 0.17 | 0.07 | | |
| ### torch.compile and TensorRT | |
| | model | input | time: portable | compile | TensorRT (fp16 unless shown) | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) | | |
| | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | |
| | `raft-large` | 1080x1920 | 283 ms | 195 ms | fails: unsupported: TensorRT 11 build at 1080x1920 needs a 20 GB My | 83.4 ms | 41.3 s | β | 5721 / 5758 | 5886 / 5924 | 332 / 352 | β | | |
| | `raft-large` | 384x1248 | 72.5 ms | β | fails: unsupported: all-pairs correlation volume at 1080x1920: a Te | β | β | β | 468 / 650 | β | β | β | | |
| | `raft-large-kitti` | 1080x1920 | 284 ms | 195 ms | fails: unsupported: TensorRT 11 build at 1080x1920 needs a 20 GB My | 84.2 ms | 39.3 s | β | 5721 / 5758 | 5886 / 5924 | 332 / 352 | β | | |
| | `raft-large-kitti` | 384x1248 | 46.2 ms | β | fails: unsupported: all-pairs correlation volume at 1080x1920: a Te | β | β | β | 469 / 522 | β | β | β | | |
| | `raft-large-things` | 1080x1920 | 283 ms | 195 ms | fails: unsupported: TensorRT 11 build at 1080x1920 needs a 20 GB My | 83.5 ms | 39.4 s | β | 5721 / 5758 | 5886 / 5924 | 332 / 352 | β | | |
| | `raft-large-things` | 384x1248 | 72.7 ms | β | fails: unsupported: all-pairs correlation volume at 1080x1920: a Te | β | β | β | 468 / 650 | β | β | β | | |
| | `raft-small` | 1080x1920 | 141 ms | 110 ms | fails: unsupported: engine build needs more than the 16 GB of this | 36.5 ms | 37.0 s | β | 5601 / 5646 | 5704 / 5728 | 196 / 204 | β | | |
| | `raft-small` | 384x1248 | 29.1 ms | β | 20.7 ms, fp32 engine | β | β | 178 s | 404 / 488 | β | β | 803 / 820 | | |
| 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 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 | |
| Frames _10 -> _11 at full size against the flow_occ ground truth; EPE = mean of the per-pair mean end-point error, Fl-all = share of all valid pixels with an error > 3 px and > 5 % of the GT magnitude. The fixed-shape comparison pads the bottom and right with edge pixels to 384 x 1248. Metrics use predictions cropped to each original ground-truth grid. Original = the original code named under Details, same checkpoint and protocol. | |
| | variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | portable + torch.compile | TensorRT | note | | |
| |---|---|---|---|---|---|---|---|---|---| | |
| | `raft-large` | KITTI 2015 train, EPE / Fl-all % | 1.528 / 5.60 | 1.528 / 5.60 | 1.529 / 5.61 | 1.528 / 5.60 | 1.526 / 5.60 | | | trained on this dataset's public images; not a zero-shot result | | |
| | `raft-large` | KITTI 2015 train (200 pairs), fixed 384 x 1248, EPE / Fl-all % | | | | 1.535 / 5.71 | | | 1.535 / 5.71 | trained on this dataset's public images; not a zero-shot result | | |
| | `raft-large` | KITTI 2015 first 50 train pairs, 384 x 1248, EPE / Fl-all % | | | | 1.322 / 4.75 | | | 1.322 / 4.75 | trained on this dataset's public images; not a zero-shot result | | |
| | `raft-large-things` | KITTI 2015 train, EPE / Fl-all % | 4.838 / 16.55 | 4.831 / 16.54 | 4.828 / 16.51 | 4.838 / 16.55 | 4.834 / 16.53 | | | | | |
| | `raft-large-things` | KITTI 2015 train (200 pairs), fixed 384 x 1248, EPE / Fl-all % | | | | 5.952 / 17.59 | | | 5.949 / 17.59 | | | |
| | `raft-large-kitti` | KITTI 2015 train, EPE / Fl-all % | 0.614 / 1.44 | 0.614 / 1.44 | 0.614 / 1.44 | 0.614 / 1.44 | 0.614 / 1.44 | | | trained on this dataset's public images; not a zero-shot result | | |
| | `raft-large-kitti` | KITTI 2015 train (200 pairs), fixed 384 x 1248, EPE / Fl-all % | | | | 0.629 / 1.50 | | | 0.629 / 1.50 | trained on this dataset's public images; not a zero-shot result | | |
| | `raft-large-kitti` | KITTI 2015 train (200 pairs) at 384 x 1248 FP16, EPE / Fl-all % | | | 0.629 / 1.50 | | | 0.629 / 1.50 | 0.629 / 1.50 | trained on this dataset's public images; not a zero-shot result | | |
| | `raft-small` | KITTI 2015 train, EPE / Fl-all % | 7.854 / 25.91 | 7.838 / 25.92 | 7.846 / 25.92 | 7.854 / 25.91 | 7.834 / 25.92 | | | | | |
| | `raft-small` | KITTI 2015 train (200 pairs), fixed 384 x 1248, EPE / Fl-all % | | | | 10.318 / 28.25 | | | 10.325 / 28.26 | | | |
| | `raft-small` | KITTI 2015 first 50 train pairs, 384 x 1248, EPE / Fl-all % | | | | 6.001 / 22.39 | | | 5.985 / 22.37 | | | |
| Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks ac98cac8 / f2992269+uncommitted, 2026-11-09 to 2026-11-18; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6f0a70e1 / ac98cac8, 2026-11-17 to 2026-11-18; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f2992269+uncommitted, 2026-11-09; compile: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 23765f70, 2026-11-19; tensorrt: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks ac98cac8, 2026-11-18. | |
| ### 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.00012 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0019 and p99 <= 0.0091 (absolute error of the output `flow`). | |
| ## Usage | |
| ```python | |
| from fastforks import flow | |
| model = flow.load("raft-large") # mode="auto": the preferred backend from recorded measurements | |
| result = model("frame1.png", "frame2.png") | |
| result.flow # [2, H, W] float32 tensor: dx, dy in input pixels | |
| 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: `raft-large`, `raft-large-kitti`, `raft-large-things`, `raft-small`. | |
| ## Kernels backend | |
| `flow.load("raft-large", mode="kernels")` runs our CUDA kernels (`raft_flow`, `cutlass_conv`, `cudnn_hacc`). 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 0d8c365f7 (2026-12-02) --> | |