coex / README.md
Flor's picture
fastforks 0.1.0
32d6f76
|
Raw History Blame Contribute Delete
6.27 kB
---
library_name: "fastforks"
pipeline_tag: "depth-estimation"
license: "other"
license_name: "gpl-3.0-only-code-weights-unstated"
license_link: "https://github.com/antabangun/coex/blob/a98b37d33f37754582b1e71f38216af8c69f2347/LICENSE"
tags:
- "stereo"
- "stereo-matching"
- "disparity"
- "cuda"
- "pytorch"
- "fastforks"
---
# CoEx (fastforks)
CoEx (Bangunharcana et al. 2021): MobileNetV2 features, an attention-weighted correlation volume, 3-D aggregation with guided cost excitation, top-2 soft-argmax and superpixel upsampling (max disparity 192).
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/antabangun/coex> at `a98b37d33f37`.
Task: stereo. Tier: stable. 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`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/stereo/models/coex/card.toml).
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
| `coex-sceneflow@1` | [sceneflow.ckpt](https://www.dropbox.com/s/c1v2r74tlbrrmsr/sceneflow.ckpt?dl=1) | `e618be2d75cd` | GPL-3.0-only (assumed from code) | yes |
## Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: GPL-3.0-only. Files: `LICENSE`.
Code licence: GPL-3.0-only; the authors do not state a separate weights licence.
Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa).
- Licence note: The code is GPL-3.0 (copyleft) and ships in the separate fastforks-nc distribution (`pip install 'fastforks-core[nc]'`); the authors state no weights licence.
Licence evidence: <https://github.com/antabangun/coex/blob/a98b37d33f37754582b1e71f38216af8c69f2347/LICENSE>
## Input size
any H x W >= 32, padded to a multiple of 32
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `coex-sceneflow` 3000x4000 (8.5 GiB peak allocated, 10.7 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 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `coex-sceneflow` | 94.9 | 60.0 | 49.9 | 23.5 | 2.6x | 2.1x | 2098 / 2160 | 1136 / 1254 | 495 / 886 |
### Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- |
| `coex-sceneflow` | – | 0.16 | 0.09† | 0.63 (375x1242) | 0.06† | 0.04† |
### 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) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `coex-sceneflow` | 994x1482 | 49.9 | 29.4 | 22.4 | 20.6 | 57 | 23.5 | 1136 / 1254 | 351 / 452 | 360 |
### Fixed-size speed and peak memory, all models
| model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 |
| --- | --- | --- | --- | --- | --- |
| `coex-sceneflow` | portable | 11.2 ms / 225 / 312 | 28.5 ms / 671 / 890 | 70.0 ms / 1485 / 1916 | 554.7 ms / 8660 / 10964 |
| `coex-sceneflow` | kernels | 4.3 ms / 103 / 322 | 13.7 ms / 256 / 400 | 32.9 ms / 559 / 804 | 211.1 ms / 3190 / 4410 |
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 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 |
|---|---|---|---|---|---|---|
| `coex-sceneflow` | ETH3D two-view train, bad > 1 px % / EPE | 33.43 / 16.021 | 33.46 / 15.995 | 33.46 / 15.989 | 33.46 / 16.000 | |
| `coex-sceneflow` | Middlebury 2014 trainingH, bad > 2 px % / EPE | 32.25 / 7.417 | 32.24 / 7.418 | 32.32 / 7.428 | 32.31 / 7.421 | |
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.
## Limitations
- SceneFlow-only weights: zero-shot output on real images is poor, so this is mainly a latency reference.
- The original code's KITTI weights (in its git repository) are not included.
## Usage
```python
from fastforks import stereo
model = stereo.load("coex-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: `coex-sceneflow`.
## Kernels backend
`stereo.load("coex-sceneflow", mode="kernels")` runs our CUDA kernels (`igev`, `cutlass_conv`, `cudnn_hacc`, `stereo_ops`). 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 feccac41 (2026-11-06) -->