card: update from fastforks 1cbf1671
Browse files
README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: "fastforks"
|
| 3 |
+
pipeline_tag: "image-to-image"
|
| 4 |
+
license: "apache-2.0"
|
| 5 |
+
tags:
|
| 6 |
+
- "flow"
|
| 7 |
+
- "optical-flow"
|
| 8 |
+
- "motion-estimation"
|
| 9 |
+
- "cuda"
|
| 10 |
+
- "pytorch"
|
| 11 |
+
- "fastforks"
|
| 12 |
+
- "fastforks-card"
|
| 13 |
+
---
|
| 14 |
+
# MemFlow (fastforks)
|
| 15 |
+
|
| 16 |
+
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 %.
|
| 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/DQiaole/MemFlow> at `5486fb88a55b`.
|
| 19 |
+
|
| 20 |
+
Task: flow. Tier: experimental. Outputs: `flow`. Backends: `portable`, `kernels`.
|
| 21 |
+
|
| 22 |
+
Input: two RGB images (consecutive frames). Output: per-pixel motion from the first to the second (dx, dy in pixels).
|
| 23 |
+
|
| 24 |
+
## Variants
|
| 25 |
+
|
| 26 |
+
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).
|
| 27 |
+
|
| 28 |
+
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|
| 29 |
+
|---|---|---|---|---|
|
| 30 |
+
| `memflow@1` | [MemFlowNet_things.pth](https://github.com/DQiaole/MemFlow/releases/download/v1.0.0/MemFlowNet_things.pth) | `694cc33c1ac5` | Apache-2.0 | yes |
|
| 31 |
+
| `memflow-kitti@1` | [MemFlowNet_kitti.pth](https://github.com/DQiaole/MemFlow/releases/download/v1.0.0/MemFlowNet_kitti.pth) | `c3ecadb24486` | Apache-2.0 | yes |
|
| 32 |
+
| `memflow-sintel@1` | [MemFlowNet_sintel.pth](https://github.com/DQiaole/MemFlow/releases/download/v1.0.0/MemFlowNet_sintel.pth) | `47c0ecd56761` | Apache-2.0 | yes |
|
| 33 |
+
|
| 34 |
+
## Licence
|
| 35 |
+
|
| 36 |
+
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: `LICENSE`.
|
| 37 |
+
|
| 38 |
+
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).
|
| 39 |
+
|
| 40 |
+
Licence evidence: <https://github.com/DQiaole/MemFlow/blob/5486fb88a55b04c2e2b292b3abaa7641d9988831/LICENSE>
|
| 41 |
+
|
| 42 |
+
## Input size
|
| 43 |
+
|
| 44 |
+
any H x W >= 128, padded to a multiple of 8
|
| 45 |
+
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)
|
| 46 |
+
|
| 47 |
+
## Speed and memory
|
| 48 |
+
|
| 49 |
+
### Flow, synthetic
|
| 50 |
+
|
| 51 |
+
| model | input | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|
| 52 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 53 |
+
| `memflow` | 1080x1920 | β | 3116 | 964 | 865 | 3.6x | 1.1x | 15061 / 15594 | 8265 / 8382 | 968 / 1022 |
|
| 54 |
+
| `memflow-kitti` | 1080x1920 | β | 3247 | 965 | 865 | 3.8x | 1.1x | 15061 / 15594 | 8265 / 8382 | 968 / 1022 |
|
| 55 |
+
| `memflow-sintel` | 1080x1920 | β | 3214 | 964 | 865 | 3.7x | 1.1x | 15061 / 15634 | 8265 / 8382 | 968 / 1022 |
|
| 56 |
+
|
| 57 |
+
### Startup and first call
|
| 58 |
+
|
| 59 |
+
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|
| 60 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 61 |
+
| `memflow` | 0.16 | 0.06 | 1.18 | 3.82 | 0.97 | 0.88 |
|
| 62 |
+
| `memflow-kitti` | 0.14 | 0.14 | 0.97 | 3.06 | 0.98 | 0.88 |
|
| 63 |
+
| `memflow-sintel` | 0.14 | 0.10 | 0.95 | 3.06 | 0.98 | 0.88 |
|
| 64 |
+
|
| 65 |
+
### torch.compile and TensorRT
|
| 66 |
+
|
| 67 |
+
| 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) |
|
| 68 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 69 |
+
| `memflow` | 1080x1920 | 964 ms | 1642 ms | fails: TensorRT engine build failed | 865 ms | 78.9 s | β | 8265 / 8382 | 6813 / 6946 | 968 / 1022 | β |
|
| 70 |
+
| `memflow-kitti` | 1080x1920 | 965 ms | 1644 ms | fails: TensorRT engine build failed | 865 ms | 72.6 s | β | 8265 / 8382 | 6813 / 6946 | 968 / 1022 | β |
|
| 71 |
+
| `memflow-sintel` | 1080x1920 | 964 ms | 1640 ms | fails: TensorRT engine build failed | 865 ms | 76.0 s | β | 8265 / 8382 | 6813 / 6946 | 968 / 1022 | β |
|
| 72 |
+
|
| 73 |
+
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
|
| 74 |
+
|
| 75 |
+
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.
|
| 76 |
+
|
| 77 |
+
## Accuracy
|
| 78 |
+
|
| 79 |
+
### On public datasets
|
| 80 |
+
|
| 81 |
+
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.
|
| 82 |
+
|
| 83 |
+
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|
| 84 |
+
|---|---|---|---|---|---|---|
|
| 85 |
+
| `memflow` | KITTI 2015 train, EPE / Fl-all % | 4.108 / 14.43 | 4.107 / 14.43 | 4.109 / 14.44 | 4.103 / 14.42 | |
|
| 86 |
+
| `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 |
|
| 87 |
+
|
| 88 |
+
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks db9e79d5+uncommitted, 2026-11-13.
|
| 89 |
+
|
| 90 |
+
### Parity with the original code
|
| 91 |
+
|
| 92 |
+
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`).
|
| 93 |
+
|
| 94 |
+
## Limitations
|
| 95 |
+
|
| 96 |
+
- 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.
|
| 97 |
+
- The MemFlow-T checkpoints (Twins-SVT encoders) and MemFlow-P (flow prediction) are not ported.
|
| 98 |
+
|
| 99 |
+
## Usage
|
| 100 |
+
|
| 101 |
+
```python
|
| 102 |
+
from fastforks import flow
|
| 103 |
+
|
| 104 |
+
model = flow.load("memflow") # mode="auto": the preferred backend from recorded measurements
|
| 105 |
+
result = model("frame1.png", "frame2.png")
|
| 106 |
+
result.flow # [2, H, W] float32 tensor: dx, dy in input pixels
|
| 107 |
+
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `memflow`, `memflow-kitti`, `memflow-sintel`.
|
| 111 |
+
|
| 112 |
+
## Kernels backend
|
| 113 |
+
|
| 114 |
+
`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.
|
| 115 |
+
|
| 116 |
+
<!-- staged from fastforks 1cbf1671 (2026-11-15) -->
|