MoCha-Stereo (fastforks)
MoCha-Stereo (Chen et al. 2024): EfficientNetV2-L features, a motif channel correlation volume next to an IGEV-style geometry volume, 3-level Mogrifier LSTM updates and a refinement step, 32 iterations. mocha-v2-sceneflow is an unofficial reconstruction (the authors released no V2 code).
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/ZYangChen/MoCha-Stereo at 78c5889c467f.
Task: stereo. Tier: experimental. Outputs: disparity. Backends: portable, kernels.
Input: a rectified left / right image pair. Output: a disparity map (pixels, left view).
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 |
|---|---|---|---|---|
mocha-v1-sceneflow@1 |
mocha-stereo.pth | 4d26f51d6321 |
MIT (assumed from code) | yes |
mocha-v2-sceneflow@1 |
mocha-V2.pth | b7cd8969158b |
MIT (assumed from code) | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Files: LICENSE.
Code licence: MIT; the authors do not state a separate weights licence.
Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa).
Licence evidence: https://github.com/ZYangChen/MoCha-Stereo/blob/78c5889c467fe31414c9425f1280afc0a8f6c1a0/README.md#L69
Input size
any H x W >= 32, padded to a multiple of 32
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): mocha-v1-sceneflow 3000x4000 (12.2 GiB peak allocated, 15.2 reserved); mocha-v2-sceneflow 3000x4000 (12.2 GiB peak allocated, 14.8 reserved)
Speed and memory
Stereo, Middlebury 2014 half, 994x1482
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|---|---|---|---|---|---|---|---|---|---|
mocha-v1-sceneflow |
2148 | 1456 | 1057 | 455 | 3.2x | 2.3x | 3637 / 3982 | 1632 / 1770 | 1588 / 1730 |
mocha-v2-sceneflow |
2054 | 1295 | 1033 | 448 | 2.9x | 2.3x | 3576 / 3982 | 1632 / 1770 | 1587 / 1790 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
mocha-v1-sceneflow |
1.95 (375x1242) | 0.79 | 0.48โ | 1.85 (375x1242) | 1.06โ | 0.45โ |
mocha-v2-sceneflow |
2.37 (375x1242) | 1.30 | 0.45โ | 0.40 (375x1242) | 1.03โ | 0.45โ |
torch.compile and TensorRT
| model | input | portable ms | compile ms | compile s (cold) | TensorRT fp16 ms | ONNX + build s | kernels ms | peak MiB (alloc / reserved): portable | compile | TensorRT (device) |
|---|---|---|---|---|---|---|---|---|---|---|
mocha-v2-sceneflow |
994x1482 | 1033 | 712.6 | 148.1 | 437.0 | 361 | 448 | 1632 / 1770 | 1122 / 1308 | 1098 |
Fixed-size speed and peak memory, all models
| model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 |
|---|---|---|---|---|---|
mocha-v1-sceneflow |
portable | 231.1 ms / 500 / 662 | 628.3 ms / 1078 / 1438 | 1484.8 ms / 2164 / 2688 | 10361.4 ms (n=3) / 12466 / 15520 |
mocha-v1-sceneflow |
kernels | 135.4 ms / 495 / 694 | 317.0 ms / 1055 / 1338 | 718.5 ms / 2092 / 2484 | 4396.8 ms (n=3) / 11664 / 14958 |
mocha-v2-sceneflow |
portable | 227.0 ms / 500 / 662 | 613.9 ms / 1078 / 1438 | 1451.9 ms / 2164 / 2688 | 10135.5 ms (n=3) / 12464 / 15164 |
mocha-v2-sceneflow |
kernels | 133.6 ms / 494 / 654 | 312.9 ms / 1054 / 1456 | 709.3 ms / 2091 / 2482 | 4316.6 ms (n=3) / 11664 / 14404 |
Apple silicon (MPS)
| model | portable |
kernels |
speed-up |
|---|---|---|---|
mocha-v1-sceneflow |
2734 ms / 2403 MiB (float16) | 2277 ms / 2382 MiB | 1.20x |
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 authors' code 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
Original = the authors' code, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|---|---|---|---|---|---|---|
mocha-v1-sceneflow |
ETH3D two-view train, bad > 1 px % / EPE | 4.35 / 1.087 | 4.35 / 1.084 | 4.35 / 1.085 | 4.35 / 1.088 | |
mocha-v1-sceneflow |
Middlebury 2014 trainingH, bad > 2 px % / EPE | 9.56 / 2.584 | 9.57 / 2.582 | 9.57 / 2.588 | 9.56 / 2.588 | |
mocha-v2-sceneflow |
ETH3D two-view train, bad > 1 px % / EPE | 3.84 / 0.892 | 3.83 / 0.885 | 3.83 / 0.887 | 3.82 / 0.886 | |
mocha-v2-sceneflow |
Middlebury 2014 trainingH, bad > 2 px % / EPE | 10.76 / 2.838 | 10.78 / 2.843 | 10.73 / 2.844 | 10.77 / 2.833 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-05.
Parity with the original code
Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.02 px and p99 <= 0.25 px.
Usage
from fastforks import stereo
model = stereo.load("mocha-v1-sceneflow") # mode="auto": the preferred backend from recorded measurements
result = model("left.png", "right.png")
result.disparity # [H, W] float32 tensor, input resolution
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: mocha-v1-sceneflow, mocha-v2-sceneflow.
Kernels backend
stereo.load("mocha-v1-sceneflow", mode="kernels") runs our CUDA kernels (igev, mocha, cutlass_conv, cudnn_hacc). 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.