A Transformers-style Python library for stereo depth estimation — inference, evaluation, and fine-tuning
Project description
stereo_matching
A unified Python library for stereo depth estimation
Inference - CLI - 3D Visualization - Model Comparison
stereo_matching provides a single, consistent API across 8 model families and 31 registered variant IDs. You can swap RAFT-Stereo, CREStereo, AANet, FoundationStereo, IGEV-Stereo, IGEV++, S2M2, and UniMatch without rewriting your preprocessing or postprocessing code.
It is built around the practical stereo workflow: run inference with one line, inspect models from the CLI, and turn calibrated disparity into depth maps and point clouds with the same library.
Installation
pip install stereo_matching
See docs/dependencies.md for optional extras such as stereo_matching[viz].
Quickstart
The pipeline API is the fastest way to run any registered stereo model:
from stereo_matching import pipeline
pipe = pipeline("stereo-matching", model="raft-stereo")
result = pipe("left.png", "right.png", focal_length=721.5, baseline=0.54)
disparity = result.disparity # np.ndarray, float32, (H, W)
depth_map = result.depth # np.ndarray, float32, (H, W) or None
colored = result.colored_disparity # np.ndarray, uint8, (H, W, 3)
For full control over preprocessing, forward pass, and postprocessing, use Auto Classes:
from stereo_matching import AutoStereoModel, AutoProcessor
import torch
model = AutoStereoModel.from_pretrained("igev-stereo", device="cuda")
processor = AutoProcessor.from_pretrained("igev-stereo")
inputs = processor("left.png", "right.png")
with torch.no_grad():
disparity = model(inputs["left_values"].cuda(), inputs["right_values"].cuda())
result = processor.postprocess(disparity, inputs["original_sizes"], colorize=True)
Or from the command line:
stereo-matching predict --left left.png --right right.png --model raft-stereo
Why use stereo_matching?
1. One API, every model.
Switch from RAFT-Stereo to FoundationStereo or UniMatch by changing a single string. pipeline(), AutoStereoModel, and AutoProcessor keep the calling pattern consistent across families.
2. Consistent model loading.
Registered variants resolve through the same pipeline(), AutoStereoModel, and AutoProcessor entry points, so model selection stays simple even as the registry grows.
3. Self-contained model packages.
Each family lives under src/stereo_matching/models/<family>/ with a config file, a single vendored modeling file, and lazy self-registration in the global registry.
4. Calibrated outputs beyond disparity.
Pass focal_length and baseline once and the library can return metric depth, colorized disparity, and point clouds for export or interactive viewing.
Supported Models
8 model families - 31 registered IDs - see docs/models.md for the full list and per-variant notes.
All families support pipeline(), Auto Classes, and CLI prediction.
| Family | Variants |
|---|---|
| RAFT-Stereo | raft-stereo, raft-stereo-middlebury, raft-stereo-eth3d, raft-stereo-realtime |
| CREStereo | crestereo |
| AANet | aanet, aanet-kitti2012, aanet-sceneflow |
| FoundationStereo | foundation-stereo, foundation-stereo-large |
| IGEV-Stereo | 6 registered IDs (igev-stereo*) |
| IGEV++ | 6 registered IDs (igev-plusplus*) |
| S2M2 | s2m2, s2m2-m, s2m2-l, s2m2-xl |
| UniMatch | 5 registered IDs (unimatch*) |
What can you do?
Inference - single pair, batch, or local script
# Single stereo pair
result = pipe("left.png", "right.png")
# Batch
results = pipe(
["left0.png", "left1.png"],
["right0.png", "right1.png"],
batch_size=2,
)
# CLI prediction
stereo-matching predict --left left.png --right right.png --model raft-stereo --output-dir results/
# Run the packaged demo script across registered models
python examples/demo.py
Auto Classes - registry-based loading for registered variants
from stereo_matching import AutoStereoModel, AutoProcessor
model = AutoStereoModel.from_pretrained("foundation-stereo", device="cuda")
processor = AutoProcessor.from_pretrained("foundation-stereo")
Use stereo-matching list-models to inspect the full registry and stereo-matching info --model <id> to print a model config from the terminal.
3D Visualization - point clouds, PLY, and GLB export
from stereo_matching import pipeline, viz
import numpy as np
from PIL import Image
pipe = pipeline("stereo-matching", model="raft-stereo")
result = pipe("left.png", "right.png", focal_length=721.5, baseline=0.54)
left_rgb = np.array(Image.open("left.png").convert("RGB"))
viz.point_cloud(
result,
image=left_rgb,
focal_length=721.5,
baseline=0.54,
save_ply="scene.ply",
save_glb="scene.glb",
)
Install stereo_matching[viz] for the optional open3d viewer path. See docs/pipeline.md for output details.
Model Comparison Demo - hosted Hugging Face Space and local Gradio app
Hosted demo: StereoMatching Compare Demo
pip install gradio gradio_sync3dcompare
python examples/compare_demo.py
The demo runs two stereo models on the same pair and shows disparity and 3D outputs side-by-side in a synchronized viewer.
Documentation
- docs/models.md - families, variants, and checkpoint sources
- docs/pipeline.md -
pipeline(),StereoOutput, and processing details - docs/cli.md -
predict,list-models, andinfo - docs/dependencies.md - optional extras and model-specific requirements
- docs/adding_a_model.md - registry and package structure
Adding a New Model
- Create
src/stereo_matching/models/your_model/ - Add
configuration_your_model.py - Add
modeling_your_model.py - Add
__init__.pywithMODEL_REGISTRY.register(...) - Import the package in
src/stereo_matching/__init__.py
AutoStereoModel, AutoProcessor, and pipeline() resolve the new model automatically. See docs/adding_a_model.md for the full pattern.
Acknowledgments
This library builds on the work of 8 stereo matching research families. See docs/models.md#citations for the citation block.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stereo_matching-0.1.0.tar.gz.
File metadata
- Download URL: stereo_matching-0.1.0.tar.gz
- Upload date:
- Size: 108.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5750d4209de16ef0e4e682ccfb406d5a26b8288abebfaac4928951dfee6608d
|
|
| MD5 |
c086aaab4f6ce139a441424bdd8c3fa8
|
|
| BLAKE2b-256 |
e93b7fdc546919b157a4ad45babe11a6975abbaaf5bbc60c1f45e87022a912dc
|
Provenance
The following attestation bundles were made for stereo_matching-0.1.0.tar.gz:
Publisher:
python-publish.yml on shriarul5273/stereo_matching
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stereo_matching-0.1.0.tar.gz -
Subject digest:
c5750d4209de16ef0e4e682ccfb406d5a26b8288abebfaac4928951dfee6608d - Sigstore transparency entry: 1186297954
- Sigstore integration time:
-
Permalink:
shriarul5273/stereo_matching@58e3f4436b45288559006ffacc200dca22c948dc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/shriarul5273
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@58e3f4436b45288559006ffacc200dca22c948dc -
Trigger Event:
release
-
Statement type:
File details
Details for the file stereo_matching-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stereo_matching-0.1.0-py3-none-any.whl
- Upload date:
- Size: 120.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b538833f3ad06570bc26d456e0a3f7098600b2d72205ddebf450abd8d2078527
|
|
| MD5 |
b5c5880fe68915826677f57f33a6617c
|
|
| BLAKE2b-256 |
81f03862c2e747d18c194d6d186987227889527a0783ab7b9eeb92e1bce66427
|
Provenance
The following attestation bundles were made for stereo_matching-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on shriarul5273/stereo_matching
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stereo_matching-0.1.0-py3-none-any.whl -
Subject digest:
b538833f3ad06570bc26d456e0a3f7098600b2d72205ddebf450abd8d2078527 - Sigstore transparency entry: 1186297959
- Sigstore integration time:
-
Permalink:
shriarul5273/stereo_matching@58e3f4436b45288559006ffacc200dca22c948dc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/shriarul5273
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@58e3f4436b45288559006ffacc200dca22c948dc -
Trigger Event:
release
-
Statement type: