Flor commited on
Commit
deb2bfd
Β·
verified Β·
1 Parent(s): 0af8d36

card: update from fastforks 1cbf1671

Browse files
Files changed (1) hide show
  1. README.md +121 -0
README.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: "fastforks"
3
+ pipeline_tag: "image-to-image"
4
+ license: "bsd-3-clause"
5
+ tags:
6
+ - "flow"
7
+ - "optical-flow"
8
+ - "motion-estimation"
9
+ - "cuda"
10
+ - "pytorch"
11
+ - "fastforks"
12
+ - "fastforks-card"
13
+ ---
14
+ # MEMFOF (fastforks)
15
+
16
+ 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 %.
17
+
18
+ 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`.
19
+
20
+ 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>.
21
+
22
+ Task: flow. Tier: experimental. Outputs: `flow`. Backends: `portable`, `kernels`.
23
+
24
+ Input: two RGB images (consecutive frames). Output: per-pixel motion from the first to the second (dx, dy in pixels).
25
+
26
+ ## Variants
27
+
28
+ 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).
29
+
30
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
31
+ |---|---|---|---|---|
32
+ | `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 |
33
+ | `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 |
34
+ | `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 |
35
+ | `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 |
36
+
37
+ ## Licence
38
+
39
+ 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`.
40
+
41
+ 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).
42
+
43
+ Licence evidence: <https://huggingface.co/egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH/blob/6c6c9aa3ad64f93aee8efbc2f7a6e4535814ee96/README.md>
44
+
45
+ ## Input size
46
+
47
+ - `memfof`, `memfof-spring`: any H x W >= 256, padded to a multiple of 16
48
+ - `memfof-kitti`, `memfof-sintel`: any H x W >= 128, padded to a multiple of 16
49
+ 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)
50
+
51
+ ## Speed and memory
52
+
53
+ ### Flow, synthetic
54
+
55
+ | model | input | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
56
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
57
+ | `memfof` | 1080x1920 | – | 531 | 433 | 427 | 1.2x | 1.0x | 2003 / 2144 | 1911 / 2196 | 1301 / 1418 |
58
+ | `memfof-kitti` | 375x1242 | – | 927 | 386 | 380 | 2.4x | 1.0x | 1968 / 2276 | 1619 / 1856 | 1137 / 1218 |
59
+ | `memfof-sintel` | 375x1242 | – | 894 | – | – | – | – | 1968 / 2176 | – | – |
60
+ | `memfof-spring` | 1080x1920 | – | 1035 | 433 | – | – | – | 2340 / 2676 | 1900 / 2196 | – |
61
+
62
+ ### Startup and first call
63
+
64
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
65
+ | --- | --- | --- | --- | --- | --- | --- |
66
+ | `memfof` | 2.06 | 0.22 (375x1242) | 1.84 (375x1242) | 1.29 | 0.41 (375x1242) | 0.29 (375x1242) |
67
+ | `memfof-kitti` | 2.59 (375x1242) | 0.21 (375x1242) | 1.07 (375x1242) | 0.96 (375x1242) | 0.65 (375x1242) | 0.56 (375x1242) |
68
+ | `memfof-sintel` | 1.30 (375x1242) | 0.69 (375x1242) | – | 0.90 (375x1242) | 0.57 (375x1242) | – |
69
+ | `memfof-spring` | 1.12 | 0.71 | – | 1.04 | 0.43 | – |
70
+
71
+ ### torch.compile and TensorRT
72
+
73
+ | 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) |
74
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
75
+ | `memfof` | 1080x1920 | 433 ms | 291 ms | 160 ms | 427 ms | 50.5 s | 110 s | 1911 / 2196 | 2452 / 2666 | 1301 / 1418 | 2070 / 2132 |
76
+ | `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 | – |
77
+ | `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 | – | – | – | – | – | – | – |
78
+ | `memfof-spring` | 1080x1920 | 433 ms | 291 ms | 160 ms | – | 45.4 s | 95.8 s | 1900 / 2196 | 2452 / 2666 | – | 2070 / 2112 |
79
+
80
+ Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
81
+
82
+ 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.
83
+
84
+ ## Accuracy
85
+
86
+ ### On public datasets
87
+
88
+ 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.
89
+
90
+ | variant | dataset | original fp32 | original fp16 | portable | kernels | note |
91
+ |---|---|---|---|---|---|---|
92
+ | `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 |
93
+
94
+ Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 087f1817+uncommitted, 2026-11-12.
95
+
96
+ ### Parity with the original code
97
+
98
+ 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`).
99
+
100
+ ## Limitations
101
+
102
+ - 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.
103
+
104
+ ## Usage
105
+
106
+ ```python
107
+ from fastforks import flow
108
+
109
+ model = flow.load("memfof") # mode="auto": the preferred backend from recorded measurements
110
+ result = model("frame1.png", "frame2.png")
111
+ result.flow # [2, H, W] float32 tensor: dx, dy in input pixels
112
+ result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
113
+ ```
114
+
115
+ Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `memfof`, `memfof-kitti`, `memfof-sintel`, `memfof-spring`.
116
+
117
+ ## Kernels backend
118
+
119
+ `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.
120
+
121
+ <!-- staged from fastforks 1cbf1671 (2026-11-15) -->