MEMFOF (fastforks)

MEMFOF (Bargatin et al. 2025): memory-efficient multi-frame optical flow. A RAFT-style network at 1/16 resolution on three frames: a ResNet34 context encoder on all three, a GMA attention over the context, 1024-channel features with an all-pairs correlation pyramid toward the previous and the next frame, a ConvNeXt update block and convex 16x upsampling; it predicts the backward and the forward flow of the middle frame at once. The authors' released weights; the network is ported from msu-video-group/memfof. A pair (image1, image2) runs as upstream's first frame of a clip, the frames (image1, image1, image2), and returns its forward flow. Paper (three frames per prediction, the fine-tuned checkpoints): Spring test 1px 3.289 %, Sintel test EPE 0.963 (clean), KITTI 2015 test Fl-all 2.94 %.

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/msu-video-group/memfof at a51de9fc59c6.

Author weight repos: https://huggingface.co/egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH, https://huggingface.co/egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH-kitti, https://huggingface.co/egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH-sintel, https://huggingface.co/egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH-spring.

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
memfof@1 MEMFOF-Tartan-T-TSKH.safetensors 5e1388c0d6de BSD-3-Clause yes
memfof-kitti@1 MEMFOF-Tartan-T-TSKH-kitti.safetensors 747da9a7919d BSD-3-Clause yes
memfof-sintel@1 MEMFOF-Tartan-T-TSKH-sintel.safetensors 5f5dfcb7f66d BSD-3-Clause yes
memfof-spring@1 MEMFOF-Tartan-T-TSKH-spring.safetensors 8ed211222294 BSD-3-Clause 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, LICENSE-torchvision.

Training data: TartanAir, Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa), MPI Sintel optical flow, KITTI stereo / optical flow 2012 / 2015, HCI HD1K optical flow benchmark (TartanAir, FlyingThings3D (part of SceneFlow), then a mix of FlyingThings3D, Sintel, KITTI 2015 and HD1K (TSKH), as upstream's config/train/*.json).

Licence evidence: https://huggingface.co/egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH/blob/6c6c9aa3ad64f93aee8efbc2f7a6e4535814ee96/README.md

Input size

  • memfof, memfof-spring: any H x W >= 256, padded to a multiple of 16
  • memfof-kitti, memfof-sintel: any H x W >= 128, padded to a multiple of 16 Tested up to (portable, fp16, RTX 5060 Ti 16 GB): memfof 1988x2880 (9.0 GiB peak allocated, 10.6 reserved); memfof-kitti 1024x1024 (5.2 GiB peak allocated, 6.1 reserved); memfof-sintel 1024x1024 (5.2 GiB peak allocated, 6.1 reserved); memfof-spring 1988x2880 (9.0 GiB peak allocated, 10.6 reserved)

Speed and memory

Flow, 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
memfof 1080x1920 – 531 433 427 1.2x 1.0x 2003 / 2144 1911 / 2196 1301 / 1418
memfof-kitti 375x1242 – 927 386 380 2.4x 1.0x 1968 / 2276 1619 / 1856 1137 / 1218
memfof-sintel 375x1242 – 894 – – – – 1968 / 2176 – –
memfof-spring 1080x1920 – 1035 433 – – – 2340 / 2676 1900 / 2196 –

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
memfof 2.06 0.22 (375x1242) 1.84 (375x1242) 1.29 0.41 (375x1242) 0.29 (375x1242)
memfof-kitti 2.59 (375x1242) 0.21 (375x1242) 1.07 (375x1242) 0.96 (375x1242) 0.65 (375x1242) 0.56 (375x1242)
memfof-sintel 1.30 (375x1242) 0.69 (375x1242) – 0.90 (375x1242) 0.57 (375x1242) –
memfof-spring 1.12 0.71 – 1.04 0.43 –

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)
memfof 1080x1920 433 ms 291 ms 160 ms 427 ms 50.5 s 110 s 1911 / 2196 2452 / 2666 1301 / 1418 2070 / 2132
memfof-kitti 375x1242 386 ms 258 ms fails: unsupported: engine build needs more than the 16 GB of this 380 ms 48.7 s – 1619 / 1856 2041 / 2226 1137 / 1218 –
memfof-sintel 1080x1920 – fails: OutOfMemoryError: CUDA out of memory. Tried to allocate 1.96 fails: OutOfMemoryError: CUDA out of memory. Tried to allocate 3.91 – – – – – – –
memfof-spring 1080x1920 433 ms 291 ms 160 ms – 45.4 s 95.8 s 1900 / 2196 2452 / 2666 – 2070 / 2112

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. Original = the original code named under Details, same checkpoint and protocol.

variant dataset original fp32 original fp16 portable kernels note
memfof KITTI 2015 train, EPE / Fl-all % 10.892 / 27.07 10.891 / 27.07 10.891 / 27.07 10.891 / 27.07 trained on this dataset's public images; not a zero-shot result

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 087f1817+uncommitted, 2026-11-12.

Parity with the original code

Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 1e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.00099 and p99 <= 0.0068 (absolute error of the output flow).

Limitations

  • Pairs only: the multi-frame input (a previous frame and the feature cache of upstream's video demo) is not exposed; each pair runs as the first frame of a clip.

Usage

from fastforks import flow

model = flow.load("memfof")  # 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: memfof, memfof-kitti, memfof-sintel, memfof-spring.

Kernels backend

flow.load("memfof", mode="kernels") runs our CUDA kernels (raft_flow). 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/memfof