Skip to main content

Hierarchical Retrieval and Memory Management for 3D Gaussian Splatting

Project description

M2M Gaussian Splatting

Python 3.10+ Code style: black

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:

  1. Fork the repository

  2. Create feature branch (git checkout -b feature/amazing)

  3. Commit changes (git commit -m 'Add amazing feature')

  4. Push to branch (git push origin feature/amazing)

  5. Open a Pull Request


๐Ÿ“„ License

MIT License - see LICENSE for details.


๐Ÿ™ Acknowledgments


๐Ÿ“ง 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

m2m_gaussian_splatting-1.1.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

m2m_gaussian_splatting-1.1.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

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

Hashes for m2m_gaussian_splatting-1.1.0.tar.gz
Algorithm Hash digest
SHA256 961787ed9a5f7949f77228cfc27d9fa22822bec1110bae9105daef6b6a5b5522
MD5 17e8a24b316ed37a6b631634b86ba5f3
BLAKE2b-256 8141e255d7dc9e181083b63ac3d712efa9ab2d0f9323bdabe5c68d1dedf53793

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file m2m_gaussian_splatting-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for m2m_gaussian_splatting-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8120ed542f58404a2a76bb1f6493dcc98daad24b9cba708801bb14f212bda0f6
MD5 1b1a66d7707326c4eec031a07514ace3
BLAKE2b-256 a4d56c71924596a231c7cd46fd9d902b2002c402b7571489cb1b0ed421cbe383

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page