SpatialHub
A lightweight spatial computing and perception library providing PyTorch-free ONNX Runtime inference adapters for computer vision models.
Key Principles
- Framework Decoupling: Core runtime paths execute on ONNX Runtime without requiring PyTorch at inference time.
- Pure NumPy & OpenCV Processing: Preprocessing, resizing, dynamic padding, coordinate projections, and alignment solvers use pure NumPy and OpenCV vector operations.
- Automatic Weight Management: Automatically retrieves, verifies, and caches pretrained
.onnxmodel weights from Hugging Face Hub. - Standardized API Contracts: Unified dataclass return structures (
MatchResult,DepthPredictionResult,FeatureExtractionResult,SegmentationResult).
Supported Models & Technical References
| Model Architecture | Task | Default Variant / Option | Returned Dataclass | Documentation & Export Guide |
|---|---|---|---|---|
| EfficientLoFTR | Semi-dense Feature Matching | "full" or "opt" |
MatchResult |
Technical Reference & Export Guide |
| Depth Anything 3 | Monocular & Multi-View Depth | "da3_base" (small/large/giant/metric/nested) |
DepthPredictionResult |
Technical Reference & Export Guide |
| DINOv2 | Image Feature Extraction | "dinov2_vitl14" (vits14/vitb14/vitg14) |
FeatureExtractionResult |
Technical Reference & Export Guide |
| FastSAM | Instance Proposal Segmentation | "FastSAM-x" or "FastSAM-s" |
SegmentationResult |
Technical Reference & Export Guide |
| SAM | Automatic Mask Generation (AMG) | "sam_vit_h" (vit_l/vit_b) |
SegmentationResult |
Technical Reference & Export Guide |
| CNOS | CAD Zero-Shot Object Detection | 3D CAD Mesh (.ply, .obj, .stl) |
SegmentationResult |
Technical Reference & Export Guide |
Installation
Requires Python 3.12+.
pip install spatialhub
For GPU acceleration (CUDA):
pip install "spatialhub[gpu]"
For 3D CAD mesh rendering support (Pyrender & Trimesh):
pip install "spatialhub[render]"
Quickstart
from spatialhub import EfficientLoFTR, DepthAnything3, DINOV2, FastSAM, SAM, CNOS
# 1. Feature Matching (EfficientLoFTR)
matcher = EfficientLoFTR()
match_res = matcher.match("img1.jpg", "img2.jpg", max_dim=1024)
match_res.visualize(top_k=50, save_path="matches.png")
# 2. Depth Estimation (Depth Anything 3)
estimator = DepthAnything3(model_name="da3_base")
depth_res = estimator.estimate_depth(images=["view1.png", "view2.png"])
depth_viz = estimator.visualize(depth_res.depth[0])
# 3. Feature Embeddings (DINOv2)
dino = DINOV2(model_variant="dinov2_vitl14")
feat_res = dino.extract_features("image.png", l2_normalize=True)
# 4. Proposal Segmentation (FastSAM)
fastsam = FastSAM(model_variant="FastSAM-x")
seg_res = fastsam.generate_masks("scene.png", conf_threshold=0.3)
seg_res.visualize_mask(save_path="fastsam_masks.png")
Reproducible ONNX Export Workflow
Each model directory under src/spatialhub/models/<model>/ contains its own pyproject.toml environment configuration and export_onnx.py script. To modify PyTorch source code or export custom ONNX graphs:
cd src/spatialhub/models/efficient_loftr
uv sync
uv run python export_onnx.py --checkpoint weights/model.ckpt --output-path weights/model.onnx
See the Reproducible ONNX Export Guide for full instructions.
License
Core SpatialHub code is released under the Apache 2.0 License. Individual pretrained model weights and submodule architectures maintain their respective original licenses.
Release files for spatialhub 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| spatialhub-0.1.4.tar.gz | 2.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spatialhub-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.3 MB
Release files / spatialhub-0.1.4.tar.gz
| Download URL | spatialhub-0.1.4.tar.gz |
|---|---|
| Size | 2.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79ab57f477d21d8f5eacc911924469b1c7c58893a3f2c570bb624a054e7537ea
|
|
BLAKE2b-256 checksum How to use checksums |
c0b36dd52eb2f1eb92b7a9ad64a28db4fa65c77d66baba7f09c20c6b186678d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / spatialhub-0.1.4-py3-none-any.whl
| Download URL | spatialhub-0.1.4-py3-none-any.whl |
|---|---|
| Size | 2.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19480efa20f9a27442e1b7357f85fa770edcc4a6d72900d7ab7745245a831366
|
|
BLAKE2b-256 checksum How to use checksums |
0e51cbee470ddc3a12eea02bd3a4ba592748dc663951045aedd38d7dce204a9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|