Hierarchical Retrieval and Memory Management for 3D Gaussian Splatting
Project description
M2M Gaussian Splatting
Hierarchical Retrieval and Memory Management for 3D Gaussian Splatting
M2M Gaussian Splatting provides fast similarity search and efficient memory management for large-scale 3D Gaussian splat datasets. Optimized for CPU with Numba JIT compilation.
โจ Features
- Hierarchical Indexing (HRM2) - Two-level clustering for fast retrieval
- 640D Embeddings - Position, color, and attribute encodings
- Numba JIT Acceleration - 5-10x speedup over pure Python
- Memory Management - Three-tier memory (VRAM/RAM/Disk)
- High Recall - >90% recall at 50x+ speedup
- CPU Optimized - No GPU required
๐ฆ Installation
# Clone repository
git clone https://github.com/schwabauerbriantomas-gif/m2m-gaussian-splatting.git
cd m2m-gaussian-splatting
# Install dependencies
pip install -r requirements.txt
# Or with pip
pip install numpy numba scipy scikit-learn
๐ Quick Start
from src.core import GaussianSplat, HRM2Engine, generate_test_splats
# Generate test data
splats = generate_test_splats(n_splats=10000)
# Create and index
engine = HRM2Engine(n_coarse=50, n_fine=200)
engine.add_splats(splats)
engine.index()
# Query for similar splats (use the engine's embeddings)
query = engine.embeddings[0] # Use first splat's embedding
results = engine.query(query, k=10)
for splat, distance in results:
print(f"Splat {splat.id}: distance={distance:.4f}")
๐ Performance
Benchmarks on ryzen 5 3400g (640D embeddings, k=10):
| Splats | Build (s) | Linear (ms) | HRM2 (ms) | Speedup | Recall |
|---|---|---|---|---|---|
| 10,000 | 1.2 | 12.5 | 0.8 | 15x | 95% |
| 50,000 | 5.8 | 62.0 | 1.5 | 41x | 93% |
| 100,000 | 12.0 | 125.0 | 2.2 | 57x | 91% |
๐ง Architecture
Embedding (640D)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 640D Embedding โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Position (64D) โ Color (512D) โ Attributes (64D) โ
โ Sinusoidal PE โ Histogram โ Opacity/Scale โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
HRM2 Index
Query Vector
โ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ Level 1: Coarse โ โ K-Means (100 clusters)
โ Find nearest โ
โโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ Level 2: Fine โ โ K-Means (1000 clusters)
โ Search within โ
โโโโโโโโโโโโโโโโโโโโ
โ
โผ
Top-K Results
๐ Project Structure
m2m-gaussian-splatting/
โโโ src/
โ โโโ core/
โ โ โโโ splat_types.py # Data structures
โ โ โโโ encoding.py # Numba JIT encoders
โ โ โโโ clustering.py # K-Means implementation
โ โ โโโ hrm2_engine.py # Hierarchical retrieval
โ โโโ memory/
โ โโโ manager.py # Memory tiers
โโโ scripts/
โ โโโ quick_demo.py # Getting started
โ โโโ run_benchmarks.py # Performance tests
โโโ tests/
โ โโโ test_*.py
โโโ docs/
โ โโโ ARCHITECTURE.md
โโโ requirements.txt
โโโ README.md
๐ฏ Use Cases
3D Scene Retrieval
Find similar regions in large 3D scans.
# Find similar scene regions
results = engine.query(region_embedding, k=20)
Asset Search
Search through millions of 3D assets.
# Find assets with similar appearance
similar = engine.query(asset_embedding, k=10)
Point Cloud Processing
Efficient queries on LiDAR data.
# Find points matching a pattern
matches = engine.query(pattern_embedding, k=100)
๐งช Running Tests
# Run all tests
python -m pytest tests/ -v
# Run with coverage
python -m pytest tests/ --cov=src
# Run benchmarks
python scripts/run_benchmarks.py
๐ API Reference
GaussianSplat
splat = GaussianSplat(
id=0,
position=[x, y, z], # 3D position
color=[r, g, b], # RGB color
opacity=0.9, # Transparency
scale=[sx, sy, sz], # Scale factors
rotation=[w, x, y, z] # Quaternion
)
HRM2Engine
engine = HRM2Engine(
n_coarse=100, # Coarse clusters
n_fine=1000, # Fine clusters
n_probe=5, # Clusters to search
)
engine.add_splats(splats)
engine.index()
results = engine.query(query_vector, k=10)
SplatMemoryManager
memory = SplatMemoryManager(
vram_limit=100000, # Hot tier
ram_limit=1000000, # Warm tier
)
memory.add_splats(splats)
splat = memory.get_splat(splat_id)
๐ฌ Technical Details
Position Encoding (64D)
NeRF-style multi-frequency sinusoidal encoding:
PE(x, 2i) = sin(x_norm * 2^i)
PE(x, 2i+1) = cos(x_norm * 2^i)
where x_norm is the coordinate normalized to [0, 1].
Color Encoding (512D)
Histogram-based with Gaussian smoothing:
- 8 bins per channel
- 8ยณ = 512 total dimensions
- Smoothed with Gaussian kernel
K-Means Implementation
- K-Means++ initialization
- Numba JIT for speed
- Parallel distance computation
๐ค Contributing
Contributions welcome! Please:
-
Fork the repository
-
Create feature branch (
git checkout -b feature/amazing) -
Commit changes (
git commit -m 'Add amazing feature') -
Push to branch (
git push origin feature/amazing) -
Open a Pull Request
๐ License
MIT License - see LICENSE for details.
๐ Acknowledgments
- 3D Gaussian Splatting - Kerbl et al.
- Numba - JIT compilation
- scikit-learn - Reference implementations
๐ง Contact
Brian Schwabauer - schwabauerbriantomas@gmail.com
Project: https://github.com/schwabauerbriantomas-gif/m2m-gaussian-splatting
๐ Keywords
gaussian-splatting 3dgs hierarchical-retrieval vector-search numba kmeans similarity-search point-cloud 3d-reconstruction nerf embedding cpu-optimized memory-management hrm2 clustering jit-compilation python
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 m2m_gaussian_splatting-1.1.0.tar.gz.
File metadata
- Download URL: m2m_gaussian_splatting-1.1.0.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
961787ed9a5f7949f77228cfc27d9fa22822bec1110bae9105daef6b6a5b5522
|
|
| MD5 |
17e8a24b316ed37a6b631634b86ba5f3
|
|
| BLAKE2b-256 |
8141e255d7dc9e181083b63ac3d712efa9ab2d0f9323bdabe5c68d1dedf53793
|
Provenance
The following attestation bundles were made for m2m_gaussian_splatting-1.1.0.tar.gz:
Publisher:
m2m-gaussian-splatting.yaml on schwabauerbriantomas-gif/m2m-gaussian-splatting
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
m2m_gaussian_splatting-1.1.0.tar.gz -
Subject digest:
961787ed9a5f7949f77228cfc27d9fa22822bec1110bae9105daef6b6a5b5522 - Sigstore transparency entry: 2065167689
- Sigstore integration time:
-
Permalink:
schwabauerbriantomas-gif/m2m-gaussian-splatting@99cc6afc08c7731677059d53be6247da4b7747d5 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/schwabauerbriantomas-gif
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
m2m-gaussian-splatting.yaml@99cc6afc08c7731677059d53be6247da4b7747d5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file m2m_gaussian_splatting-1.1.0-py3-none-any.whl.
File metadata
- Download URL: m2m_gaussian_splatting-1.1.0-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8120ed542f58404a2a76bb1f6493dcc98daad24b9cba708801bb14f212bda0f6
|
|
| MD5 |
1b1a66d7707326c4eec031a07514ace3
|
|
| BLAKE2b-256 |
a4d56c71924596a231c7cd46fd9d902b2002c402b7571489cb1b0ed421cbe383
|
Provenance
The following attestation bundles were made for m2m_gaussian_splatting-1.1.0-py3-none-any.whl:
Publisher:
m2m-gaussian-splatting.yaml on schwabauerbriantomas-gif/m2m-gaussian-splatting
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
m2m_gaussian_splatting-1.1.0-py3-none-any.whl -
Subject digest:
8120ed542f58404a2a76bb1f6493dcc98daad24b9cba708801bb14f212bda0f6 - Sigstore transparency entry: 2065167864
- Sigstore integration time:
-
Permalink:
schwabauerbriantomas-gif/m2m-gaussian-splatting@99cc6afc08c7731677059d53be6247da4b7747d5 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/schwabauerbriantomas-gif
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
m2m-gaussian-splatting.yaml@99cc6afc08c7731677059d53be6247da4b7747d5 -
Trigger Event:
release
-
Statement type: