|
Download README.md from fastforks/memflow: direct link, hf CLI and curl.
- Browser
- Download file 7.76 kB
-
https://huggingface.co/fastforks/memflow/resolve/main/README.md
- Command line
-
hf download hf://fastforks/memflow/README.md
-
curl -L -o README.md https://huggingface.co/fastforks/memflow/resolve/main/README.md
7.76 kB
| library_name: "fastforks" | |
| pipeline_tag: "image-to-image" | |
| license: "apache-2.0" | |
| tags: | |
| - "flow" | |
| - "optical-flow" | |
| - "motion-estimation" | |
| - "cuda" | |
| - "pytorch" | |
| - "fastforks" | |
| - "fastforks-card" | |
| # MemFlow (fastforks) | |
| MemFlow (Dong & Fu, CVPR 2024): optical flow with a memory of past motion. A RAFT-style network at 1/8 resolution: BasicEncoder feature and context networks, an all-pairs correlation pyramid, a motion encoder and update block of depthwise-separable large-kernel blocks (SKFlow) instead of a GRU, and an attention readout of the motion features of memory frames; convex 8x upsampling. The authors' released weights; the network is ported from DQiaole/MemFlow. A pair (image1, image2) runs as upstream's first frame of a video (empty memory: the readout attends over the pair's own motion features). Paper (video with memory, val_decoder_depth 15): Sintel test EPE 1.05 (clean) / 1.91 (final), KITTI 2015 test Fl-all 4.10 %. | |
| 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/DQiaole/MemFlow> at `5486fb88a55b`. | |
| 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/memflow/card.toml). | |
| | variant | weights (author link) | SHA-256 | weights licence | commercial use | | |
| |---|---|---|---|---| | |
| | `memflow@1` | [MemFlowNet_things.pth](https://github.com/DQiaole/MemFlow/releases/download/v1.0.0/MemFlowNet_things.pth) | `694cc33c1ac5` | Apache-2.0 | yes | | |
| | `memflow-kitti@1` | [MemFlowNet_kitti.pth](https://github.com/DQiaole/MemFlow/releases/download/v1.0.0/MemFlowNet_kitti.pth) | `c3ecadb24486` | Apache-2.0 | yes | | |
| | `memflow-sintel@1` | [MemFlowNet_sintel.pth](https://github.com/DQiaole/MemFlow/releases/download/v1.0.0/MemFlowNet_sintel.pth) | `47c0ecd56761` | Apache-2.0 | yes | | |
| ## Licence | |
| Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: `LICENSE`. | |
| Training data: FlyingChairs (Freiburg), Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa) (FlyingThings3D (part of SceneFlow), starting from SKFlow's FlyingChairs + FlyingThings3D checkpoint, as upstream's train.sh). | |
| Licence evidence: <https://github.com/DQiaole/MemFlow/blob/5486fb88a55b04c2e2b292b3abaa7641d9988831/LICENSE> | |
| ## Input size | |
| any H x W >= 128, padded to a multiple of 8 | |
| Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `memflow` 1024x2048 (8.2 GiB peak allocated, 9.2 reserved); `memflow-kitti` 1024x2048 (8.2 GiB peak allocated, 9.2 reserved); `memflow-sintel` 1024x2048 (8.2 GiB peak allocated, 9.2 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 | | |
| | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | |
| | `memflow` | 1080x1920 | β | 3116 | 964 | 865 | 3.6x | 1.1x | 15061 / 15594 | 8265 / 8382 | 968 / 1022 | | |
| | `memflow-kitti` | 1080x1920 | β | 3247 | 965 | 865 | 3.8x | 1.1x | 15061 / 15594 | 8265 / 8382 | 968 / 1022 | | |
| | `memflow-sintel` | 1080x1920 | β | 3214 | 964 | 865 | 3.7x | 1.1x | 15061 / 15634 | 8265 / 8382 | 968 / 1022 | | |
| ### Startup and first call | |
| | model | load (s): original | portable | kernels | first call (s): original | portable | kernels | | |
| | --- | --- | --- | --- | --- | --- | --- | | |
| | `memflow` | 0.16 | 0.06 | 1.18 | 3.82 | 0.97 | 0.88 | | |
| | `memflow-kitti` | 0.14 | 0.14 | 0.97 | 3.06 | 0.98 | 0.88 | | |
| | `memflow-sintel` | 0.14 | 0.10 | 0.95 | 3.06 | 0.98 | 0.88 | | |
| ### 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) | | |
| | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | |
| | `memflow` | 1080x1920 | 964 ms | 1642 ms | fails: TensorRT engine build failed | 865 ms | 78.9 s | β | 8265 / 8382 | 6813 / 6946 | 968 / 1022 | β | | |
| | `memflow-kitti` | 1080x1920 | 965 ms | 1644 ms | fails: TensorRT engine build failed | 865 ms | 72.6 s | β | 8265 / 8382 | 6813 / 6946 | 968 / 1022 | β | | |
| | `memflow-sintel` | 1080x1920 | 964 ms | 1640 ms | fails: TensorRT engine build failed | 865 ms | 76.0 s | β | 8265 / 8382 | 6813 / 6946 | 968 / 1022 | β | | |
| 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 | | |
| |---|---|---|---|---|---|---| | |
| | `memflow` | KITTI 2015 train, EPE / Fl-all % | 4.108 / 14.43 | 4.107 / 14.43 | 4.109 / 14.44 | 4.103 / 14.42 | | | |
| | `memflow-kitti` | KITTI 2015 train, EPE / Fl-all % | 0.600 / 1.21 | 0.600 / 1.21 | 0.600 / 1.21 | 0.600 / 1.21 | 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 db9e79d5+uncommitted, 2026-11-13. | |
| ### Parity with the original code | |
| Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 4.2e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0018 and p99 <= 0.0065 (absolute error of the output `flow`). | |
| ## Limitations | |
| - Pairs only: the video memory (the keys and values of earlier frames that upstream's inference keeps) is not exposed; each pair runs as the first frame of a video. | |
| - The MemFlow-T checkpoints (Twins-SVT encoders) and MemFlow-P (flow prediction) are not ported. | |
| ## Usage | |
| ```python | |
| from fastforks import flow | |
| model = flow.load("memflow") # 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: `memflow`, `memflow-kitti`, `memflow-sintel`. | |
| ## Kernels backend | |
| `flow.load("memflow", 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) --> | |