GMFlow (fastforks)
GMFlow (Xu, Zhang, Cai, Rezatofighi & Tao 2022) in its UniMatch release (Xu et al. 2023): optical flow as global matching. A CNN gives features at 1/8 resolution, a Transformer with self- and cross-attention (shifted windows) makes the two images' features aware of each other, the flow is the expected position of the best match over the whole image, and a self-attention layer spreads it into occluded areas. scale2 variants repeat this at 1/4 resolution with local matching; regrefine6 variants add 6 RAFT-like local refinements.
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/autonomousvision/unimatch at 943a99006950.
Task: flow. Tier: experimental. 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.
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
gmflow-scale1-mixdata@1 |
gmflow-scale1-mixdata-train320x576-4c3a6e9a.pth | 4c3a6e9af913 |
MIT AND Apache-2.0 AND BSD-3-Clause (assumed from code) | yes |
gmflow-scale1-things@1 |
gmflow-scale1-things-e9887eda.pth | e9887eda6165 |
MIT AND Apache-2.0 AND BSD-3-Clause (assumed from code) | yes |
gmflow-scale2-mixdata@1 |
gmflow-scale2-mixdata-train320x576-9ff1c094.pth | 9ff1c094f496 |
MIT AND Apache-2.0 AND BSD-3-Clause (assumed from code) | yes |
gmflow-scale2-regrefine6-kitti@1 |
gmflow-scale2-regrefine6-kitti15-25b554d7.pth | 25b554d766e9 |
MIT AND Apache-2.0 AND BSD-3-Clause (assumed from code) | yes |
gmflow-scale2-regrefine6-mixdata@1 |
gmflow-scale2-regrefine6-mixdata-train320x576-4e7b215d.pth | 4e7b215d5a25 |
MIT AND Apache-2.0 AND BSD-3-Clause (assumed from code) | yes |
gmflow-scale2-regrefine6-sintelft@1 |
gmflow-scale2-regrefine6-sintelft-6e39e2b9.pth | 6e39e2b9fb0f |
MIT AND Apache-2.0 AND BSD-3-Clause (assumed from code) | yes |
gmflow-scale2-regrefine6-things@1 |
gmflow-scale2-regrefine6-things-776ed612.pth | 776ed612efb8 |
MIT AND Apache-2.0 AND BSD-3-Clause (assumed from code) | yes |
gmflow-scale2-sintel@1 |
gmflow-scale2-sintel-3ed1cf48.pth | 3ed1cf486cf7 |
MIT AND Apache-2.0 AND BSD-3-Clause (assumed from code) | yes |
gmflow-scale2-things@1 |
gmflow-scale2-things-36579974.pth | 365799747d9f |
MIT AND Apache-2.0 AND 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: MIT AND Apache-2.0 AND BSD-3-Clause. Licence files: LICENSE, LICENSE-Apache-2.0, LICENSE-RAFT.
Code licence: MIT AND Apache-2.0 AND 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/autonomousvision/unimatch/blob/943a99006950ab6c84ea72a72beb147fdd03c19a/MODEL_ZOO.md
Input size
gmflow-scale1-mixdata,gmflow-scale1-things: any H x W >= 64, padded to a multiple of 16gmflow-scale2-mixdata,gmflow-scale2-regrefine6-kitti,gmflow-scale2-regrefine6-mixdata,gmflow-scale2-regrefine6-sintelft,gmflow-scale2-regrefine6-things,gmflow-scale2-sintel,gmflow-scale2-things: any H x W >= 64, padded to a multiple of 32 Tested up to (portable, fp16, RTX 5060 Ti 16 GB):gmflow-scale1-mixdata1024x2048 (5.4 GiB peak allocated, 6.0 reserved);gmflow-scale1-things1024x2048 (5.4 GiB peak allocated, 6.0 reserved);gmflow-scale2-mixdata1024x2048 (6.3 GiB peak allocated, 13.1 reserved);gmflow-scale2-regrefine6-kitti1024x2048 (6.3 GiB peak allocated, 13.1 reserved);gmflow-scale2-regrefine6-mixdata1024x2048 (6.3 GiB peak allocated, 13.1 reserved);gmflow-scale2-regrefine6-sintelft1024x2048 (6.3 GiB peak allocated, 13.1 reserved);gmflow-scale2-regrefine6-things1024x2048 (6.3 GiB peak allocated, 13.1 reserved);gmflow-scale2-sintel1024x2048 (6.3 GiB peak allocated, 13.1 reserved);gmflow-scale2-things1024x2048 (6.3 GiB peak allocated, 13.1 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 |
|---|---|---|---|---|---|---|---|---|---|
gmflow-scale1-mixdata |
1246 | 750 | 448 | 446 | 1.7x | 1.0x | 8360 / 8448 | 1988 / 2142 | 1988 / 2142 |
gmflow-scale1-things |
1245 | 750 | 448 | 446 | 1.7x | 1.0x | 8360 / 8468 | 1988 / 2142 | 1988 / 2142 |
gmflow-scale2-mixdata |
2544 | 1608 | 915 | 915 | 1.8x | 1.0x | 8425 / 8572 | 2995 / 3184 | 2995 / 3204 |
gmflow-scale2-regrefine6-kitti |
3255 | 2188 | 1383 | 1389 | 1.6x | 1.0x | 8537 / 8822 | 3005 / 3192 | 3005 / 3212 |
gmflow-scale2-regrefine6-mixdata |
3254 | 2188 | 1382 | 1383 | 1.6x | 1.0x | 8537 / 8822 | 3005 / 3192 | 3005 / 3212 |
gmflow-scale2-regrefine6-sintelft |
3255 | 2184 | 1381 | 1384 | 1.6x | 1.0x | 8537 / 8822 | 3005 / 3192 | 3005 / 3212 |
gmflow-scale2-regrefine6-things |
3230 | 2175 | 1382 | 1384 | 1.6x | 1.0x | 8537 / 8822 | 3005 / 3192 | 3005 / 3212 |
gmflow-scale2-sintel |
2541 | 1607 | 915 | 916 | 1.8x | 1.0x | 8425 / 8552 | 2995 / 3184 | 2995 / 3204 |
gmflow-scale2-things |
2537 | 1599 | 914 | 916 | 1.7x | 1.0x | 8425 / 8552 | 2995 / 3184 | 2995 / 3204 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
gmflow-scale1-mixdata |
0.13 | 0.16 | 0.16 (375x1242) | 0.76 | 0.56 | 0.57 (375x1242) |
gmflow-scale1-things |
0.14 | 0.16 | 0.16 | 0.94 | 0.56 | 0.88 |
gmflow-scale2-mixdata |
0.13 | 0.16 | 0.17 (375x1242) | 1.62 | 1.14 | 0.71 (375x1242) |
gmflow-scale2-regrefine6-kitti |
0.15 | 0.46 | 0.17 (375x1242) | 2.20 | 1.68 | 0.89 (375x1242) |
gmflow-scale2-regrefine6-mixdata |
0.14 | 0.25 | 0.17 (375x1242) | 2.20 | 1.68 | 0.89 (375x1242) |
gmflow-scale2-regrefine6-sintelft |
0.15 | 0.26 | 0.36 (375x1242) | 2.37 | 1.68 | 0.72 (375x1242) |
gmflow-scale2-regrefine6-things |
0.15 | 0.16 | 0.16 | 2.19 | 1.67 | 1.90 |
gmflow-scale2-sintel |
0.13 | 0.16 | 0.16 (375x1242) | 1.62 | 1.14 | 0.72 (375x1242) |
gmflow-scale2-things |
0.14 | 0.17 | 0.17 (375x1242) | 1.61 | 1.14 | 0.70 (375x1242) |
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) |
|---|---|---|---|---|---|---|---|---|---|---|---|
gmflow-scale1-mixdata |
1080x1920 | 448 ms | 382 ms | β | 446 ms | 29.1 s | β | 1988 / 2142 | 4293 / 4558 | 1988 / 2142 | β |
gmflow-scale1-mixdata |
1088x1920 | β | β | 187 ms (fixed 1088x1920 source pair) | β | β | 67.3 s | β | β | β | 4333 / 4390 |
gmflow-scale1-things |
1080x1920 | 448 ms | 382 ms | β | 446 ms | 35.3 s | β | 1988 / 2142 | 4293 / 4558 | 1988 / 2142 | β |
gmflow-scale1-things |
1088x1920 | β | β | 187 ms (fixed 1088x1920 source pair) | β | β | 69.3 s | β | β | β | 4333 / 4390 |
gmflow-scale2-mixdata |
1080x1920 | 915 ms | 765 ms | public API unavailable | 915 ms | 46.6 s | β | 2995 / 3184 | 10865 / 10904 | 2995 / 3204 | β |
gmflow-scale2-mixdata |
384x1248 | 210 ms | β | 212 ms, fp32 engine (standalone feature CNN, eager transformer and flow update) | β | β | 13.6 s | 1410 / 2272 | β | β | 1616 / 2560 |
gmflow-scale2-regrefine6-kitti |
1080x1920 | 1383 ms | 1116 ms | public API unavailable | 1389 ms | 58.4 s | β | 3005 / 3192 | 10875 / 10972 | 3005 / 3212 | β |
gmflow-scale2-regrefine6-kitti |
384x1248 | 349 ms | β | 351 ms, fp32 engine (standalone feature CNN, eager transformer and flow update) | β | β | 13.1 s | 1455 / 2278 | β | β | 1660 / 2526 |
gmflow-scale2-regrefine6-mixdata |
1080x1920 | 1382 ms | 1116 ms | public API unavailable | 1383 ms | 58.9 s | β | 3005 / 3192 | 10875 / 10972 | 3005 / 3212 | β |
gmflow-scale2-regrefine6-mixdata |
384x1248 | 348 ms | β | 349 ms, fp32 engine (standalone feature CNN, eager transformer and flow update) | β | β | 13.6 s | 1455 / 2278 | β | β | 1660 / 2526 |
gmflow-scale2-regrefine6-sintelft |
1080x1920 | 1381 ms | 1116 ms | public API unavailable | 1384 ms | 58.5 s | β | 3005 / 3192 | 10875 / 10972 | 3005 / 3212 | β |
gmflow-scale2-regrefine6-sintelft |
384x1248 | 349 ms | β | 350 ms, fp32 engine (standalone feature CNN, eager transformer and flow update) | β | β | 14.5 s | 1455 / 2278 | β | β | 1660 / 2526 |
gmflow-scale2-regrefine6-things |
1080x1920 | 1382 ms | 1116 ms | public API unavailable | 1384 ms | 58.2 s | β | 3005 / 3192 | 10875 / 10972 | 3005 / 3212 | β |
gmflow-scale2-regrefine6-things |
384x1248 | 348 ms | β | 350 ms, fp32 engine (standalone feature CNN, eager transformer and flow update) | β | β | 13.7 s | 1455 / 2278 | β | β | 1660 / 2526 |
gmflow-scale2-sintel |
1080x1920 | 915 ms | 765 ms | public API unavailable | 916 ms | 46.6 s | β | 2995 / 3184 | 10865 / 10904 | 2995 / 3204 | β |
gmflow-scale2-sintel |
384x1248 | 210 ms | β | 212 ms, fp32 engine (standalone feature CNN, eager transformer and flow update) | β | β | 12.7 s | 1410 / 2272 | β | β | 1616 / 2560 |
gmflow-scale2-things |
1080x1920 | 914 ms | 765 ms | public API unavailable | 916 ms | 46.7 s | β | 2995 / 3184 | 10865 / 10904 | 2995 / 3204 | β |
gmflow-scale2-things |
384x1248 | 210 ms | β | 212 ms, fp32 engine (standalone feature CNN, eager transformer and flow update) | β | β | 13.6 s | 1410 / 2272 | β | β | 1616 / 2560 |
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
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 | TensorRT | note |
|---|---|---|---|---|---|---|---|---|
gmflow-scale1-things |
KITTI 2015 train, EPE / Fl-all % | 10.347 / 34.31 | 10.347 / 34.30 | 10.346 / 34.30 | 10.347 / 34.30 | 10.346 / 34.30 | ||
gmflow-scale1-mixdata |
KITTI 2015 train, EPE / Fl-all % | 3.698 / 17.60 | 3.698 / 17.61 | 3.697 / 17.61 | 3.698 / 17.60 | 3.697 / 17.60 | possibly in the training data | |
gmflow-scale2-things |
KITTI 2015 train, EPE / Fl-all % | 6.747 / 22.09 | 6.747 / 22.09 | 6.747 / 22.09 | 6.747 / 22.09 | 6.747 / 22.09 | ||
gmflow-scale2-things |
KITTI 2015 first 10 train pairs, 384 x 1248, EPE / Fl-all % | 4.377 / 19.25 | 4.376 / 19.25 | |||||
gmflow-scale2-sintel |
KITTI 2015 train, EPE / Fl-all % | 1.975 / 7.88 | 1.976 / 7.88 | 1.975 / 7.88 | 1.975 / 7.88 | 1.975 / 7.88 | trained on this dataset's public images; not a zero-shot result | |
gmflow-scale2-sintel |
KITTI 2015 first 10 train pairs, 384 x 1248, EPE / Fl-all % | 1.240 / 6.11 | 1.240 / 6.11 | trained on this dataset's public images; not a zero-shot result | ||||
gmflow-scale2-mixdata |
KITTI 2015 train, EPE / Fl-all % | 2.390 / 10.10 | 2.390 / 10.10 | 2.389 / 10.10 | 2.390 / 10.10 | 2.389 / 10.10 | possibly in the training data | |
gmflow-scale2-mixdata |
KITTI 2015 first 10 train pairs, 384 x 1248, EPE / Fl-all % | 1.462 / 6.59 | 1.462 / 6.59 | possibly in the training data | ||||
gmflow-scale2-regrefine6-things |
KITTI 2015 train, EPE / Fl-all % | 4.918 / 16.33 | 4.918 / 16.32 | 4.917 / 16.32 | 4.918 / 16.33 | 4.915 / 16.32 | ||
gmflow-scale2-regrefine6-things |
KITTI 2015 first 10 train pairs, 384 x 1248, EPE / Fl-all % | 3.230 / 14.46 | 3.222 / 14.46 | |||||
gmflow-scale2-regrefine6-sintelft |
KITTI 2015 train, EPE / Fl-all % | 1.153 / 3.92 | 1.154 / 3.92 | 1.154 / 3.92 | 1.153 / 3.92 | 1.154 / 3.92 | trained on this dataset's public images; not a zero-shot result | |
gmflow-scale2-regrefine6-sintelft |
KITTI 2015 first 10 train pairs, 384 x 1248, EPE / Fl-all % | 0.878 / 3.43 | 0.879 / 3.43 | trained on this dataset's public images; not a zero-shot result | ||||
gmflow-scale2-regrefine6-kitti |
KITTI 2015 train, EPE / Fl-all % | 0.570 / 1.15 | 0.570 / 1.15 | 0.570 / 1.15 | 0.570 / 1.15 | 0.570 / 1.15 | trained on this dataset's public images; not a zero-shot result | |
gmflow-scale2-regrefine6-kitti |
KITTI 2015 first 10 train pairs, 384 x 1248, EPE / Fl-all % | 0.387 / 0.64 | 0.387 / 0.64 | trained on this dataset's public images; not a zero-shot result | ||||
gmflow-scale2-regrefine6-mixdata |
KITTI 2015 train, EPE / Fl-all % | 1.315 / 4.64 | 1.315 / 4.63 | 1.315 / 4.64 | 1.314 / 4.64 | 1.314 / 4.63 | possibly in the training data | |
gmflow-scale2-regrefine6-mixdata |
KITTI 2015 first 10 train pairs, 384 x 1248, EPE / Fl-all % | 0.905 / 3.66 | 0.902 / 3.63 | possibly in the training data |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks c4a67979, 2026-11-11; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6f0a70e1 / 8590735f, 2026-11-17 to 2026-11-19; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 0fba22666, 2026-11-20; tensorrt: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 8590735f, 2026-11-18 to 2026-11-19.
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.0001 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0031 and p99 <= 0.021 (absolute error of the output flow).
Limitations
- TensorRT builds at 1080x1920 fail for scale2 variants with a Myelin CHECK(is_const()) error on RTX 5060 Ti; scale1 variants build.
Usage
from fastforks import flow
model = flow.load("gmflow-scale1-mixdata") # 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: gmflow-scale1-mixdata, gmflow-scale1-things, gmflow-scale2-mixdata, gmflow-scale2-regrefine6-kitti, gmflow-scale2-regrefine6-mixdata, gmflow-scale2-regrefine6-sintelft, gmflow-scale2-regrefine6-things, gmflow-scale2-sintel, gmflow-scale2-things.
Kernels backend
flow.load("gmflow-scale1-mixdata", mode="kernels") runs our CUDA kernels (flow_upsample, gmflow). 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.