|
Download README.md from fastforks/memfof: direct link, hf CLI and curl.
- Browser
- Download file 9.27 kB
-
https://huggingface.co/fastforks/memfof/resolve/main/README.md
- Command line
-
hf download hf://fastforks/memfof/README.md
-
curl -L -o README.md https://huggingface.co/fastforks/memfof/resolve/main/README.md
9.27 kB
| library_name: "fastforks" | |
| pipeline_tag: "image-to-image" | |
| license: "bsd-3-clause" | |
| tags: | |
| - "flow" | |
| - "optical-flow" | |
| - "motion-estimation" | |
| - "cuda" | |
| - "pytorch" | |
| - "fastforks" | |
| - "fastforks-card" | |
| # 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`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/flow/models/memfof/card.toml). | |
| | variant | weights (author link) | SHA-256 | weights licence | commercial use | | |
| |---|---|---|---|---| | |
| | `memfof@1` | [MEMFOF-Tartan-T-TSKH.safetensors](https://huggingface.co/egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH/resolve/6c6c9aa3ad64f93aee8efbc2f7a6e4535814ee96/model.safetensors) | `5e1388c0d6de` | BSD-3-Clause | yes | | |
| | `memfof-kitti@1` | [MEMFOF-Tartan-T-TSKH-kitti.safetensors](https://huggingface.co/egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH-kitti/resolve/c5df484ef137ca2ab9759f3458474a525747ef4d/model.safetensors) | `747da9a7919d` | BSD-3-Clause | yes | | |
| | `memfof-sintel@1` | [MEMFOF-Tartan-T-TSKH-sintel.safetensors](https://huggingface.co/egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH-sintel/resolve/53575708ab235a6f75fdfe3c9d85218da4a6eaa4/model.safetensors) | `5f5dfcb7f66d` | BSD-3-Clause | yes | | |
| | `memfof-spring@1` | [MEMFOF-Tartan-T-TSKH-spring.safetensors](https://huggingface.co/egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH-spring/resolve/bd8e677a6bafce8872494bc880abc0a38b515657/model.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](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. 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 | |
| ```python | |
| 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. | |
| <!-- staged from fastforks 1cbf1671 (2026-11-15) --> | |