Skip to main content

Reduced-3DGS: Memory Footprint Reduction for 3D Gaussian Splatting (Python Package Version)

PyPI version Downloads Total downloads CI CI

This repository contains the refactored Python code for Reduced-3DGS. It is forked from commit 13e7393af8ecd83d69197dec7e4c891b333a7c1c. The original code has been refactored to follow the standard Python package structure, while maintaining the same algorithms as the original version.

Features

  • Code organized as a standard Python package
  • Pruning
  • SH Culling
  • Vector quantization by K-Means

Prerequisites

  • Pytorch (v2.4 or higher recommended)
  • CUDA Toolkit (12.4 recommended, should match with PyTorch version)
  • (Optional) cuML for faster vector quantization

(Optional) If you have trouble with gaussian-splatting, try to install it from source:

pip install wheel setuptools
pip install --upgrade git+https://github.com/yindaheng98/gaussian-splatting.git@master --no-build-isolation

PyPI Install

pip install --upgrade reduced-3dgs

or build latest from source:

pip install wheel setuptools
pip install --upgrade git+https://github.com/yindaheng98/reduced-3dgs.git@main --no-build-isolation

Development Install

git clone --recursive https://github.com/yindaheng98/reduced-3dgs
cd reduced-3dgs
pip install scikit-learn
pip install --target . --upgrade --no-deps .

Quick Start

  1. Download the dataset (T&T+DB COLMAP dataset, size 650MB):
wget https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/datasets/input/tandt_db.zip -P ./data
unzip data/tandt_db.zip -d data/
  1. Train 3DGS with densification, pruning, and SH culling (same as original 3DGS)
python -m reduced_3dgs.train -s data/truck -d output/truck -i 30000 --mode densify-prune-shculling
  1. Render 3DGS
python -m gaussian_splatting.render -s data/truck -d output/truck -i 30000 --mode densify

💡 Note: This repository does not include code for creating datasets. If you wish to create your own dataset, please refer to InstantSplat or use convert.py.

💡 See .vscode/launch.json for more examples. Refer to reduced_3dgs.train and gaussian_splatting.render for full options.

API Usage

This project heavily depends on gaussian-splatting and only provides some enhanced Trainers and Gaussian models. Therefore, before starting, please refer to gaussian-splatting to understand the key concepts about Gaussian models, Dataset, Trainers, and how to use them.

Pruning

BasePruningTrainer prunes the trainer at specified training steps.

from reduced_3dgs.pruning import BasePruningTrainer
trainer = BasePruningTrainer(
    gaussians,
    scene_extent=dataset.scene_extent(),
    dataset=dataset,
    prune_from_iter=1000,
    prune_until_iter=15000,
    prune_interval=100,
    ... # see reduced_3dgs/pruning/trainer.py for full options
)

BasePrunerInDensifyTrainer integrates pruning with densification.

from reduced_3dgs.pruning import BasePrunerInDensifyTrainer
trainer = BasePrunerInDensifyTrainer(
    gaussians,
    scene_extent=dataset.scene_extent(),
    dataset=dataset,
    mercy_from_iter=3000,
    mercy_until_iter=20000,
    mercy_interval=100,
    densify_from_iter=500,
    densify_until_iter=15000,
    densify_interval=100,
    densify_grad_threshold=0.0002,
    densify_opacity_threshold=0.005,
    prune_from_iter=1000,
    prune_until_iter=15000,
    prune_interval=100,
    prune_screensize_threshold=20,
    ... # see reduced_3dgs/pruning/trainer.py for full options
)

SH Culling

VariableSHGaussianModel is the 3DGS model that assigns each 3D Gaussian a different SH degree.

from reduced_3dgs.shculling import VariableSHGaussianModel
gaussians = VariableSHGaussianModel(sh_degree).to(device)

BaseSHCullingTrainer culls the SH degree of each 3D Gaussian at specified training steps.

from reduced_3dgs.shculling import BaseSHCullingTrainer
trainer = BaseSHCullingTrainer(
    gaussians,
    scene_extent=dataset.scene_extent(),
    dataset=dataset,
    cull_at_steps=[15000],
    ... # see reduced_3dgs/shculling/trainer.py for full options
)

Quantization

VectorQuantizer is the basic quantization operator:

gaussians.load_ply("output/truck")
from reduced_3dgs.quantization import VectorQuantizer
quantizer = VectorQuantizer(gaussians, num_clusters=256)
quantizer.save_quantized("output/truck-quantized")
quantizer.load_quantized("output/truck-quantized")

BaseVectorQuantizeTrainer quantizes the model at specified training steps.

from reduced_3dgs.shculling import BaseSHCullingTrainer
trainer = BaseVectorQuantizeTrainer(
    gaussians,
    spatial_lr_scale=dataset.scene_extent(),
    dataset=dataset,
    num_clusters=256,
    quantizate_from_iter=5000,
    quantizate_until_iter=30000,
    quantizate_interval=1000,
    ... # see reduced_3dgs/shculling/trainer.py for full options
)

VectorQuantizeTrainerWrapper is a wrapper that integrates the quantization step into any Trainer:

trainer = VectorQuantizeTrainerWrapper(
    trainer,

    num_clusters=num_clusters,
    num_clusters_rotation_re=num_clusters_rotation_re,
    num_clusters_rotation_im=num_clusters_rotation_im,
    num_clusters_opacity=num_clusters_opacity,
    num_clusters_scaling=num_clusters_scaling,
    num_clusters_features_dc=num_clusters_features_dc,
    num_clusters_features_rest=num_clusters_features_rest,

    quantizate_from_iter=quantizate_from_iter,
    quantizate_until_iter=quantizate_until_iter,
    quantizate_interval=quantizate_interval,
)
if load_quantized:
    trainer.quantizer.load_quantized(load_quantized)
# see reduced_3dgs/train.py

Quantized PLY Format

💡 See reduced_3dgs/quantization/quantizer.py for the code to save and load quantized PLY files.

The save_quantized function will produce a point cloud stored in a .ply format.

Previously, the layout of this file was one row per primitive, containing a series of parameters in vertex elements, namely

  • 3 floats for position (x,y,z)
  • 3 floats for normal (nx,ny,nz)
  • 1 uint for the real part of the rotation quaternion (rot_re)
  • 1 uint for the imaginary part of the rotation quaternion (rot_im)
  • 1 uint for opacity (opacity)
  • 3 uint for scaling (scale)
  • 1 uint for DC color (f_dc)
  • 3 uint for SH coefficients (f_rest_0, f_rest_1, f_rest_2)

The codebook quantization introduces some additional changes. For different parameters, you can set different lengths of the codebook. Each attribute's codebook will be stored in different elements. The codebooks are ordered as follows:

  • codebook_rot_re element contains 1 float for the real part of the rotation quaternion (rot_re)
  • codebook_rot_im element contains 3 floats for the 3 imaginary parts of the rotation quaternion (rot_im_0, rot_im_1, rot_im_2)
  • codebook_opacity element contains 1 float for the opacity (opacity)
  • codebook_scaling element contains 3 floats for the 3 parameters of scale (scaling_0, scaling_1, scaling_2)
  • codebook_f_dc element contains 3 floats for the 3 DC color parameters (f_dc_0, f_dc_1, f_dc_2)
  • 3 elements codebook_f_rest_<SH degree> contains floats for SH coefficients of 3 SH degrees (f_rest_<SH degree>_<SH coefficients at this degree>). SH degree 1 has 3 coefficients f_rest_0_<0,1,2> in codebook_f_rest_0, SH degree 2 has 5 coefficients f_rest_1_<0,1,2,3,4> in codebook_f_rest_1, SH degree 3 has 7 coefficients f_rest_2_<0,1,2,3,4,5,6> in codebook_f_rest_2.

Reducing the Memory Footprint of 3D Gaussian Splatting

Panagiotis Papantonakis Georgios Kopanas, Bernhard Kerbl, Alexandre Lanvin, George Drettakis
| Webpage | Full Paper | Datasets (TODO) | Video | Other GRAPHDECO Publications | FUNGRAPH project page |
Teaser image

This repository contains the code of the paper "Reducing the Memory Footprint of 3D Gaussian Splatting", which can be found here. We also provide the configurations to train the models mentioned in the paper, as well as the evaluation script that produces the results.

Abstract: 3D Gaussian splatting provides excellent visual quality for novel view synthesis, with fast training and real-time rendering; unfortunately, the memory requirements of this method for storing and transmission are unreasonably high. We first analyze the reasons for this, identifying three main areas where storage can be reduced: the number of 3D Gaussian primitives used to represent a scene, the number of coefficients for the spherical harmonics used to represent directional radiance, and the precision required to store Gaussian primitive attributes. We present a solution to each of these issues. First, we propose an efficient, resolution-aware primitive pruning approach, reducing the primitive count by half. Second, we introduce an adaptive adjustment method to choose the number of coefficients used to represent directional radiance for each Gaussian primitive, and finally a codebook-based quantization method, together with a half-float representation for further memory reduction. Taken together, these three components result in a ×27 reduction in overall size on disk on the standard datasets we tested, along with a ×1.7 speedup in rendering speed. We demonstrate our method on standard datasets and show how our solution results in significantly reduced download times when using the method on a mobile device

BibTeX

@Article{papantonakisReduced3DGS,
      author       = {Papantonakis, Panagiotis and Kopanas, Georgios and Kerbl, Bernhard and Lanvin, Alexandre and Drettakis, George},
      title        = {Reducing the Memory Footprint of 3D Gaussian Splatting},
      journal      = {Proceedings of the ACM on Computer Graphics and Interactive Techniques},
      number       = {1},
      volume       = {7},
      month        = {May},
      year         = {2024},
      url          = {https://repo-sam.inria.fr/fungraph/reduced_3dgs/}
}

Download files

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

Source Distribution

reduced_3dgs-1.15.1.tar.gz (71.5 kB view details)

Uploaded Source

Built Distributions

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

reduced_3dgs-1.15.1-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12Windows x86-64

reduced_3dgs-1.15.1-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11Windows x86-64

reduced_3dgs-1.15.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

reduced_3dgs-1.15.1-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10Windows x86-64

reduced_3dgs-1.15.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

Details for the file reduced_3dgs-1.15.1.tar.gz.

File metadata

  • Download URL: reduced_3dgs-1.15.1.tar.gz
  • Upload date:
  • Size: 71.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for reduced_3dgs-1.15.1.tar.gz
Algorithm Hash digest
SHA256 c02feb78a25c7a7ccb03bc6c7eaf8693798ef3c6574d785222deb3c19766dc1c
MD5 2bf6d485fca5983cf8dedbc7e033be4a
BLAKE2b-256 8110cc907c69d7267ff6171af9c080135b6ec4e8eece97234f94d8844ee53a5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for reduced_3dgs-1.15.1.tar.gz:

Publisher: build-release.yml on yindaheng98/reduced-3dgs

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

File details

Details for the file reduced_3dgs-1.15.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for reduced_3dgs-1.15.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0917efd9ae2ac8b8160a144ae2226301e49ecf3391af6d6cdca2337022e4a9a0
MD5 1e26a7ad9e6d51018e3539c2517dd8ef
BLAKE2b-256 ead6d47f81c364b637bcb08630a670c86e610c877e37ad7403ed7f9cb5346783

See more details on using hashes here.

Provenance

The following attestation bundles were made for reduced_3dgs-1.15.1-cp312-cp312-win_amd64.whl:

Publisher: build-release.yml on yindaheng98/reduced-3dgs

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

File details

Details for the file reduced_3dgs-1.15.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for reduced_3dgs-1.15.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 53b838c6e9db06ccac33a4d8ca896bd8d45b7d81127e0fafce09bde9775708f4
MD5 052d19cb1698d98fac65d289c27c9d0f
BLAKE2b-256 dd496daf11c6950ec727f6ac48f1db09e925f015ee064513c1a3d74f93353369

See more details on using hashes here.

Provenance

The following attestation bundles were made for reduced_3dgs-1.15.1-cp311-cp311-win_amd64.whl:

Publisher: build-release.yml on yindaheng98/reduced-3dgs

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

File details

Details for the file reduced_3dgs-1.15.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for reduced_3dgs-1.15.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ceeb8cf16d728c057abe860e676e973cb9df7524bd9dea6ad1ed5f0d047a5a8d
MD5 68f201e0953a3bfcd152a7c70f4c525a
BLAKE2b-256 8062a69a11d9c254fe6523618c0e69e391063d7fb8177591ba2bb2ceae996e30

See more details on using hashes here.

Provenance

The following attestation bundles were made for reduced_3dgs-1.15.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: build-release.yml on yindaheng98/reduced-3dgs

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

File details

Details for the file reduced_3dgs-1.15.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for reduced_3dgs-1.15.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 86b370da64f6df102deb98b3696faadb5ed6362ba4592f37f617f318995c236b
MD5 942ae11cb79bebc1a1d3d1f0211e7464
BLAKE2b-256 892fe2ab49b0486831cce93502fa1a49bf3df80d4d8d43d7907ced6342b32022

See more details on using hashes here.

Provenance

The following attestation bundles were made for reduced_3dgs-1.15.1-cp310-cp310-win_amd64.whl:

Publisher: build-release.yml on yindaheng98/reduced-3dgs

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

File details

Details for the file reduced_3dgs-1.15.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for reduced_3dgs-1.15.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0261203abe72fd23ccd6e5248ba80eb0d7d21f5dafa267bc9ab25f613784b83e
MD5 0fd16475d5f70f9e41f6a0dd3d1a447e
BLAKE2b-256 03209e6f5992c480159e974845f2da46aeac05e9e139323793acfec4d5729c84

See more details on using hashes here.

Provenance

The following attestation bundles were made for reduced_3dgs-1.15.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: build-release.yml on yindaheng98/reduced-3dgs

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

Release history Release notifications | RSS feed

This release

1.15.1 This release

6 files

1.14.2

6 files

1.14.1.2

6 files

1.14.1.1

6 files

1.14.1

6 files

1.14.0

4 files

1.13.1

4 files

1.13.0

4 files

1.12.8

4 files

1.12.7

4 files

1.12.6

4 files

1.12.5

4 files

1.12.4

4 files

1.12.3

6 files

1.12.2

6 files

1.12.1

6 files

1.12.0

6 files

1.11.2

6 files

1.11.1

6 files

1.11.0

6 files

1.10.13

6 files

1.10.12

6 files

1.10.11

6 files

1.10.10

6 files

1.10.9

6 files

1.10.8

6 files

1.10.7

6 files

1.10.6

6 files

1.10.5

6 files

1.10.4

6 files

1.10.3

6 files

1.10.2

6 files

1.10.1

6 files

1.10.0

6 files

1.9.5

6 files

1.9.4

6 files

1.9.3

6 files

1.9.2

6 files

1.9.1

6 files

1.9.0

6 files

1.8.19

6 files

1.8.18

6 files

1.8.17

6 files

1.8.16

6 files

1.8.15

6 files

1.8.14

6 files

1.8.13

6 files

1.8.12

6 files

1.8.11

4 files

1.8.10

4 files

1.8.9

4 files

1.8.8

4 files

1.8.7

4 files

1.8.6

4 files

1.8.5

4 files

1.8.4

4 files

1.8.3

4 files

1.8.2

4 files

1.8.1

4 files

1.8.0

4 files

1.7.0

6 files

1.6.6

6 files

1.6.5

6 files

1.6.4

6 files

1.6.3

6 files

1.6.2

6 files

1.6.1

6 files

1.6.0

6 files

1.5.0

6 files

1.4.6

6 files

1.4.5

6 files

1.4.4

6 files

1.4.3

6 files

1.4.2

6 files

1.4.1

6 files

1.4.0

6 files

1.3.15

6 files

1.3.14

6 files

1.3.13

6 files

1.3.12

6 files

1.3.11

6 files

1.3.10

6 files

1.3.9

6 files

1.3.8

6 files

1.3.7

6 files

1.3.6

6 files

1.3.5

6 files

1.3.4

6 files

1.3.3

6 files

1.3.2

6 files

1.3.1

6 files

1.3

6 files

1.2

6 files

1.1

6 files

1.0.2

6 files

1.0.1

6 files

1.0

10 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page