reduced-3dgs 1.8.14__tar.gz → 1.8.16__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of reduced-3dgs might be problematic. Click here for more details.

Files changed (48) hide show
  1. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/PKG-INFO +1 -1
  2. reduced_3dgs-1.8.16/reduced_3dgs/pruning/__init__.py +2 -0
  3. reduced_3dgs-1.8.16/reduced_3dgs/pruning/combinations.py +51 -0
  4. reduced_3dgs-1.8.16/reduced_3dgs/pruning/importance/__init__.py +1 -0
  5. reduced_3dgs-1.8.16/reduced_3dgs/pruning/importance/trainer.py +141 -0
  6. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/pruning/trainer.py +18 -75
  7. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/quantization/abc.py +1 -1
  8. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/train.py +3 -0
  9. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs.egg-info/PKG-INFO +1 -1
  10. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs.egg-info/SOURCES.txt +9 -1
  11. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/setup.py +20 -3
  12. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/diff-gaussian-rasterization/reduced_3dgs/sh_culling.cu +20 -1
  13. reduced_3dgs-1.8.16/submodules/gaussian-importance/cuda_rasterizer/backward.cu +657 -0
  14. reduced_3dgs-1.8.16/submodules/gaussian-importance/cuda_rasterizer/forward.cu +614 -0
  15. reduced_3dgs-1.8.16/submodules/gaussian-importance/cuda_rasterizer/rasterizer_impl.cu +584 -0
  16. reduced_3dgs-1.8.16/submodules/gaussian-importance/diff_gaussian_rasterization/__init__.py +347 -0
  17. reduced_3dgs-1.8.16/submodules/gaussian-importance/ext.cpp +20 -0
  18. reduced_3dgs-1.8.16/submodules/gaussian-importance/rasterize_points.cu +319 -0
  19. reduced_3dgs-1.8.14/reduced_3dgs/pruning/__init__.py +0 -2
  20. reduced_3dgs-1.8.14/reduced_3dgs/pruning/combinations.py +0 -20
  21. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/LICENSE.md +0 -0
  22. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/README.md +0 -0
  23. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/__init__.py +0 -0
  24. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/combinations.py +0 -0
  25. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/quantization/__init__.py +0 -0
  26. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/quantization/exclude_zeros.py +0 -0
  27. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/quantization/quantizer.py +0 -0
  28. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/quantization/wrapper.py +0 -0
  29. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/quantize.py +0 -0
  30. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/shculling/__init__.py +0 -0
  31. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/shculling/gaussian_model.py +0 -0
  32. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs/shculling/trainer.py +0 -0
  33. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs.egg-info/dependency_links.txt +0 -0
  34. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs.egg-info/requires.txt +0 -0
  35. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/reduced_3dgs.egg-info/top_level.txt +0 -0
  36. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/setup.cfg +0 -0
  37. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/diff-gaussian-rasterization/cuda_rasterizer/backward.cu +0 -0
  38. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/diff-gaussian-rasterization/cuda_rasterizer/forward.cu +0 -0
  39. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/diff-gaussian-rasterization/cuda_rasterizer/rasterizer_impl.cu +0 -0
  40. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py +0 -0
  41. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/diff-gaussian-rasterization/ext.cpp +0 -0
  42. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/diff-gaussian-rasterization/rasterize_points.cu +0 -0
  43. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/diff-gaussian-rasterization/reduced_3dgs/kmeans.cu +0 -0
  44. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/diff-gaussian-rasterization/reduced_3dgs/redundancy_score.cu +0 -0
  45. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/diff-gaussian-rasterization/reduced_3dgs.cu +0 -0
  46. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/simple-knn/ext.cpp +0 -0
  47. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/simple-knn/simple_knn.cu +0 -0
  48. {reduced_3dgs-1.8.14 → reduced_3dgs-1.8.16}/submodules/simple-knn/spatial.cu +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reduced_3dgs
3
- Version: 1.8.14
3
+ Version: 1.8.16
4
4
  Summary: Refactored code for the paper "Reducing the Memory Footprint of 3D Gaussian Splatting"
5
5
  Home-page: https://github.com/yindaheng98/reduced-3dgs
6
6
  Author: yindaheng98
@@ -0,0 +1,2 @@
1
+ from .trainer import BasePruner, BasePruningTrainer
2
+ from .combinations import BasePrunerInDensifyTrainer, PruningTrainer, PrunerInDensifyTrainer
@@ -0,0 +1,51 @@
1
+
2
+ from typing import List
3
+ from gaussian_splatting import Camera, GaussianModel
4
+ from gaussian_splatting.dataset import TrainableCameraDataset
5
+ from gaussian_splatting.trainer import DepthTrainerWrapper, NoopDensifier, DensificationTrainerWrapper
6
+ from .trainer import BasePruner, BasePruningTrainer
7
+
8
+
9
+ def BasePrunerInDensifyTrainer(
10
+ model: GaussianModel,
11
+ scene_extent: float,
12
+ dataset: List[Camera],
13
+ prune_from_iter=1000,
14
+ prune_until_iter=15000,
15
+ prune_interval: int = 100,
16
+ box_size=1.,
17
+ lambda_mercy=1.,
18
+ mercy_minimum=3,
19
+ mercy_type='redundancy_opacity',
20
+ *args, **kwargs):
21
+ return DensificationTrainerWrapper(
22
+ lambda model, scene_extent: BasePruner(
23
+ NoopDensifier(model),
24
+ model, dataset,
25
+ prune_from_iter=prune_from_iter,
26
+ prune_until_iter=prune_until_iter,
27
+ prune_interval=prune_interval,
28
+ box_size=box_size,
29
+ lambda_mercy=lambda_mercy,
30
+ mercy_minimum=mercy_minimum,
31
+ mercy_type=mercy_type,
32
+ ),
33
+ model,
34
+ scene_extent,
35
+ *args, **kwargs
36
+ )
37
+
38
+
39
+ # Depth trainer
40
+
41
+
42
+ def DepthPruningTrainer(model: GaussianModel, scene_extent: float, dataset: TrainableCameraDataset, *args, **kwargs):
43
+ return DepthTrainerWrapper(BasePruningTrainer, model, scene_extent, *args, dataset=dataset, **kwargs)
44
+
45
+
46
+ def DepthPrunerInDensifyTrainer(model: GaussianModel, scene_extent: float, dataset: TrainableCameraDataset, *args, **kwargs):
47
+ return DepthTrainerWrapper(BasePrunerInDensifyTrainer, model, scene_extent, *args, dataset=dataset, **kwargs)
48
+
49
+
50
+ PruningTrainer = DepthPruningTrainer
51
+ PrunerInDensifyTrainer = DepthPrunerInDensifyTrainer
@@ -0,0 +1 @@
1
+ from .trainer import ImportancePruningTrainerWrapper, BaseImportancePruningTrainer, ImportancePruningTrainer
@@ -0,0 +1,141 @@
1
+ import math
2
+ import torch
3
+
4
+ from gaussian_splatting import Camera, GaussianModel
5
+ from gaussian_splatting.trainer import AbstractTrainer, TrainerWrapper, BaseTrainer, Trainer
6
+ from gaussian_splatting.dataset import CameraDataset
7
+ from .diff_gaussian_rasterization import GaussianRasterizationSettings, GaussianRasterizer
8
+
9
+
10
+ def count_render(self: GaussianModel, viewpoint_camera: Camera):
11
+ """
12
+ Render the scene.
13
+
14
+ Background tensor (bg_color) must be on GPU!
15
+ """
16
+ # Create zero tensor. We will use it to make pytorch return gradients of the 2D (screen-space) means
17
+ screenspace_points = torch.zeros_like(self.get_xyz, dtype=self.get_xyz.dtype, requires_grad=True, device=self._xyz.device) + 0
18
+ try:
19
+ screenspace_points.retain_grad()
20
+ except:
21
+ pass
22
+
23
+ # Set up rasterization configuration
24
+ tanfovx = math.tan(viewpoint_camera.FoVx * 0.5)
25
+ tanfovy = math.tan(viewpoint_camera.FoVy * 0.5)
26
+
27
+ raster_settings = GaussianRasterizationSettings(
28
+ image_height=int(viewpoint_camera.image_height),
29
+ image_width=int(viewpoint_camera.image_width),
30
+ tanfovx=tanfovx,
31
+ tanfovy=tanfovy,
32
+ bg=viewpoint_camera.bg_color.to(self._xyz.device),
33
+ scale_modifier=self.scale_modifier,
34
+ viewmatrix=viewpoint_camera.world_view_transform,
35
+ projmatrix=viewpoint_camera.full_proj_transform,
36
+ sh_degree=self.active_sh_degree,
37
+ campos=viewpoint_camera.camera_center,
38
+ prefiltered=False,
39
+ debug=self.debug,
40
+ f_count=True,
41
+ )
42
+
43
+ rasterizer = GaussianRasterizer(raster_settings=raster_settings)
44
+ means3D = self.get_xyz
45
+ means2D = screenspace_points
46
+ opacity = self.get_opacity
47
+
48
+ scales = self.get_scaling
49
+ rotations = self.get_rotation
50
+
51
+ shs = self.get_features
52
+
53
+ # Rasterize visible Gaussians to image, obtain their radii (on screen).
54
+ gaussians_count, opacity_important_score, T_alpha_important_score, rendered_image, radii = rasterizer(
55
+ means3D=means3D,
56
+ means2D=means2D,
57
+ shs=shs,
58
+ colors_precomp=None,
59
+ opacities=opacity,
60
+ scales=scales,
61
+ rotations=rotations,
62
+ cov3D_precomp=None)
63
+
64
+ # Those Gaussians that were frustum culled or had a radius of 0 were not visible.
65
+ # They will be excluded from value updates used in the splitting criteria.
66
+ return {
67
+ "render": rendered_image,
68
+ "viewspace_points": screenspace_points,
69
+ "visibility_filter": radii > 0,
70
+ "radii": radii,
71
+ "gaussians_count": gaussians_count,
72
+ "opacity_important_score": opacity_important_score,
73
+ "T_alpha_important_score": T_alpha_important_score
74
+ }
75
+
76
+
77
+ class ImportancePruner(TrainerWrapper):
78
+ def __init__(
79
+ self, base_trainer: AbstractTrainer,
80
+ dataset: CameraDataset,
81
+ importance_prune_at_steps=[15000],
82
+ ):
83
+ super().__init__(base_trainer)
84
+ self.dataset = dataset
85
+ self.importance_prune_at_steps = importance_prune_at_steps
86
+
87
+ def optim_step(self):
88
+ ret = super().optim_step()
89
+ if self.curr_step in self.importance_prune_at_steps:
90
+ gaussian_count = torch.zeros(self.model.get_xyz.shape[0], device=self.model.get_xyz.device, dtype=torch.int)
91
+ opacity_important_score = torch.zeros(self.model.get_xyz.shape[0], device=self.model.get_xyz.device, dtype=torch.float)
92
+ T_alpha_important_score = torch.zeros(self.model.get_xyz.shape[0], device=self.model.get_xyz.device, dtype=torch.float)
93
+ for camera in self.dataset:
94
+ out = count_render(self.model, camera)
95
+ gaussian_count += out["gaussians_count"]
96
+ opacity_important_score += out["opacity_important_score"]
97
+ T_alpha_important_score += out["T_alpha_important_score"]
98
+ pass
99
+ return ret
100
+
101
+
102
+ def ImportancePruningTrainerWrapper(
103
+ base_trainer_constructor,
104
+ model: GaussianModel,
105
+ scene_extent: float,
106
+ dataset: CameraDataset,
107
+ importance_prune_at_steps=[15000],
108
+ *args, **kwargs):
109
+ return ImportancePruner(
110
+ base_trainer_constructor(model, scene_extent, dataset, *args, **kwargs),
111
+ dataset,
112
+ importance_prune_at_steps=importance_prune_at_steps,
113
+ )
114
+
115
+
116
+ def BaseImportancePruningTrainer(
117
+ model: GaussianModel,
118
+ scene_extent: float,
119
+ dataset: CameraDataset,
120
+ importance_prune_at_steps=[15000],
121
+ *args, **kwargs):
122
+ return ImportancePruningTrainerWrapper(
123
+ lambda model, scene_extent, dataset, *args, **kwargs: BaseTrainer(model, scene_extent, *args, **kwargs),
124
+ model, scene_extent, dataset,
125
+ importance_prune_at_steps=importance_prune_at_steps,
126
+ *args, **kwargs,
127
+ )
128
+
129
+
130
+ def ImportancePruningTrainer(
131
+ model: GaussianModel,
132
+ scene_extent: float,
133
+ dataset: CameraDataset,
134
+ importance_prune_at_steps=[15000],
135
+ *args, **kwargs):
136
+ return ImportancePruningTrainerWrapper(
137
+ lambda model, scene_extent, dataset, *args, **kwargs: Trainer(model, scene_extent, *args, **kwargs),
138
+ model, scene_extent, dataset,
139
+ importance_prune_at_steps=importance_prune_at_steps,
140
+ *args, **kwargs,
141
+ )
@@ -1,7 +1,7 @@
1
1
  from typing import List
2
2
  import torch
3
3
  from gaussian_splatting import GaussianModel, Camera
4
- from gaussian_splatting.trainer import AbstractDensifier, Densifier, DensificationInstruct, DensificationTrainer
4
+ from gaussian_splatting.trainer import AbstractDensifier, DensifierWrapper, DensificationTrainer, NoopDensifier
5
5
  from reduced_3dgs.diff_gaussian_rasterization._C import sphere_ellipsoid_intersection, allocate_minimum_redundancy_value, find_minimum_projected_pixel_size
6
6
  from reduced_3dgs.simple_knn._C import distIndex2
7
7
 
@@ -79,16 +79,18 @@ def mercy_gaussians(
79
79
  return mask
80
80
 
81
81
 
82
- class BasePruner(AbstractDensifier):
82
+ class BasePruner(DensifierWrapper):
83
83
  def __init__(
84
- self, model: GaussianModel, dataset: List[Camera],
84
+ self, base_densifier: AbstractDensifier,
85
+ model: GaussianModel, dataset: List[Camera],
85
86
  prune_from_iter=1000,
86
87
  prune_until_iter=15000,
87
- prune_interval: int = 500,
88
+ prune_interval: int = 100,
88
89
  box_size=1.,
89
90
  lambda_mercy=1.,
90
91
  mercy_minimum=3,
91
92
  mercy_type='redundancy_opacity'):
93
+ super().__init__(base_densifier)
92
94
  self._model = model
93
95
  self.dataset = dataset
94
96
  self.prune_from_iter = prune_from_iter
@@ -103,10 +105,12 @@ class BasePruner(AbstractDensifier):
103
105
  def model(self) -> GaussianModel:
104
106
  return self._model
105
107
 
106
- def densify_and_prune(self, loss, out, camera, step: int) -> DensificationInstruct:
107
- if self.prune_from_iter < step < self.prune_until_iter and step % self.prune_interval == 0:
108
- return DensificationInstruct(remove_mask=mercy_gaussians(self.model, self.dataset, self.box_size, self.lambda_mercy, self.mercy_minimum, self.mercy_type))
109
- return DensificationInstruct()
108
+ def densify_and_prune(self, loss, out, camera, step: int):
109
+ ret = super().densify_and_prune(loss, out, camera, step)
110
+ if self.prune_from_iter <= step <= self.prune_until_iter and step % self.prune_interval == 0:
111
+ remove_mask = mercy_gaussians(self.model, self.dataset, self.box_size, self.lambda_mercy, self.mercy_minimum, self.mercy_type)
112
+ ret = ret._replace(remove_mask=remove_mask if ret.remove_mask is None else torch.logical_or(remove_mask, ret.remove_mask))
113
+ return ret
110
114
 
111
115
 
112
116
  def BasePruningTrainer(
@@ -115,7 +119,7 @@ def BasePruningTrainer(
115
119
  dataset: List[Camera],
116
120
  prune_from_iter=1000,
117
121
  prune_until_iter=15000,
118
- prune_interval: int = 500,
122
+ prune_interval: int = 100,
119
123
  box_size=1.,
120
124
  lambda_mercy=1.,
121
125
  mercy_minimum=3,
@@ -124,75 +128,14 @@ def BasePruningTrainer(
124
128
  return DensificationTrainer(
125
129
  model, scene_extent,
126
130
  BasePruner(
131
+ NoopDensifier(),
127
132
  model, dataset,
128
- prune_from_iter, prune_until_iter, prune_interval,
129
- box_size, lambda_mercy, mercy_minimum, mercy_type
130
- ), *args, **kwargs
131
- )
132
-
133
-
134
- class PrunerInDensify(Densifier):
135
- def __init__(
136
- self, model: GaussianModel, scene_extent, dataset: List[Camera],
137
- box_size=1.,
138
- lambda_mercy=1.,
139
- mercy_minimum=3,
140
- mercy_type='redundancy_opacity',
141
- *args, **kwargs):
142
- super().__init__(model, scene_extent, *args, **kwargs)
143
- self.dataset = dataset
144
- self.box_size = box_size
145
- self.lambda_mercy = lambda_mercy
146
- self.mercy_minimum = mercy_minimum
147
- self.mercy_type = mercy_type
148
-
149
- def prune(self) -> torch.Tensor:
150
- _splatted_num_accum, _ = calculate_redundancy_metric(self.model, self.dataset, pixel_scale=self.box_size)
151
- mask = mercy_points(self.model, _splatted_num_accum.squeeze(), self.lambda_mercy, self.mercy_minimum, self.mercy_type)
152
- return torch.logical_or(mask, super().prune())
153
-
154
-
155
- def BasePrunerInDensifyTrainer(
156
- model: GaussianModel,
157
- scene_extent: float,
158
-
159
- dataset: List[Camera],
160
- box_size=1.,
161
- lambda_mercy=1.,
162
- mercy_minimum=3,
163
- mercy_type='redundancy_opacity',
164
-
165
- densify_from_iter=500,
166
- densify_until_iter=15000,
167
- densify_interval=100,
168
- densify_grad_threshold=0.0002,
169
- densify_opacity_threshold=0.005,
170
- densify_percent_dense=0.01,
171
- densify_percent_too_big=0.8,
172
-
173
- prune_from_iter=1000,
174
- prune_until_iter=15000,
175
- prune_interval=500,
176
- prune_screensize_threshold=20,
177
- prune_percent_too_big=1,
178
-
179
- *args, **kwargs):
180
- return DensificationTrainer(
181
- model, scene_extent,
182
- PrunerInDensify(
183
- model, scene_extent, dataset,
184
- box_size, lambda_mercy, mercy_minimum, mercy_type,
185
- densify_from_iter=densify_from_iter,
186
- densify_until_iter=densify_until_iter,
187
- densify_interval=densify_interval,
188
- densify_grad_threshold=densify_grad_threshold,
189
- densify_opacity_threshold=densify_opacity_threshold,
190
- densify_percent_dense=densify_percent_dense,
191
- densify_percent_too_big=densify_percent_too_big,
192
133
  prune_from_iter=prune_from_iter,
193
134
  prune_until_iter=prune_until_iter,
194
135
  prune_interval=prune_interval,
195
- prune_screensize_threshold=prune_screensize_threshold,
196
- prune_percent_too_big=prune_percent_too_big
136
+ box_size=box_size,
137
+ lambda_mercy=lambda_mercy,
138
+ mercy_minimum=mercy_minimum,
139
+ mercy_type=mercy_type,
197
140
  ), *args, **kwargs
198
141
  )
@@ -42,7 +42,7 @@ class QuantizeTrainerWrapper(TrainerWrapper, metaclass=abc.ABCMeta):
42
42
 
43
43
  @property
44
44
  def model(self) -> GaussianModel:
45
- if self.quantize_from_iter <= self.curr_step < self.quantize_until_iter and self.curr_step % self.quantize_interval == 0:
45
+ if self.quantize_from_iter <= self.curr_step <= self.quantize_until_iter and self.curr_step % self.quantize_interval == 0:
46
46
  with torch.no_grad():
47
47
  ids_dict, codebook_dict = self.quantizer.quantize(self.base_trainer.model, update_codebook=True)
48
48
  return self.quantizer.dequantize(self.base_trainer.model, ids_dict, codebook_dict)
@@ -14,6 +14,7 @@ from gaussian_splatting.trainer.extensions import ScaleRegularizeTrainerWrapper
14
14
  from reduced_3dgs.quantization import AbstractQuantizer, VectorQuantizeTrainerWrapper
15
15
  from reduced_3dgs.shculling import VariableSHGaussianModel, SHCullingTrainer
16
16
  from reduced_3dgs.pruning import PruningTrainer
17
+ from reduced_3dgs.pruning.importance import ImportancePruningTrainerWrapper
17
18
  from reduced_3dgs.combinations import OpacityResetPrunerInDensifyTrainer, SHCullingDensifyTrainer, SHCullingPruneTrainer, SHCullingPruningDensifyTrainer
18
19
  from reduced_3dgs.combinations import CameraTrainableVariableSHGaussianModel, CameraSHCullingTrainer, CameraPruningTrainer
19
20
  from reduced_3dgs.combinations import CameraOpacityResetPrunerInDensifyTrainer, CameraSHCullingDensifyTrainer, CameraSHCullingPruneTrainer, CameraSHCullingPruningDensifyTrainer
@@ -27,6 +28,7 @@ basemodes = {
27
28
  "prune-shculling": SHCullingPruneTrainer,
28
29
  "densify-prune-shculling": SHCullingPruningDensifyTrainer,
29
30
  }
31
+ basemodes = {k: lambda *args, **kwargs: ImportancePruningTrainerWrapper(v, *args, **kwargs) for k, v in basemodes.items()}
30
32
  cameramodes = {
31
33
  "camera-shculling": CameraSHCullingTrainer,
32
34
  "camera-pruning": CameraPruningTrainer,
@@ -35,6 +37,7 @@ cameramodes = {
35
37
  "camera-prune-shculling": CameraSHCullingPruneTrainer,
36
38
  "camera-densify-prune-shculling": CameraSHCullingPruningDensifyTrainer,
37
39
  }
40
+ cameramodes = {k: lambda *args, **kwargs: ImportancePruningTrainerWrapper(v, *args, **kwargs) for k, v in cameramodes.items()}
38
41
 
39
42
 
40
43
  def prepare_quantizer(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reduced_3dgs
3
- Version: 1.8.14
3
+ Version: 1.8.16
4
4
  Summary: Refactored code for the paper "Reducing the Memory Footprint of 3D Gaussian Splatting"
5
5
  Home-page: https://github.com/yindaheng98/reduced-3dgs
6
6
  Author: yindaheng98
@@ -13,6 +13,8 @@ reduced_3dgs.egg-info/top_level.txt
13
13
  reduced_3dgs/pruning/__init__.py
14
14
  reduced_3dgs/pruning/combinations.py
15
15
  reduced_3dgs/pruning/trainer.py
16
+ reduced_3dgs/pruning/importance/__init__.py
17
+ reduced_3dgs/pruning/importance/trainer.py
16
18
  reduced_3dgs/quantization/__init__.py
17
19
  reduced_3dgs/quantization/abc.py
18
20
  reduced_3dgs/quantization/exclude_zeros.py
@@ -30,7 +32,13 @@ submodules/diff-gaussian-rasterization/cuda_rasterizer/rasterizer_impl.cu
30
32
  submodules/diff-gaussian-rasterization/reduced_3dgs/kmeans.cu
31
33
  submodules/diff-gaussian-rasterization/reduced_3dgs/redundancy_score.cu
32
34
  submodules/diff-gaussian-rasterization/reduced_3dgs/sh_culling.cu
35
+ submodules/gaussian-importance/ext.cpp
36
+ submodules/gaussian-importance/rasterize_points.cu
37
+ submodules/gaussian-importance/cuda_rasterizer/backward.cu
38
+ submodules/gaussian-importance/cuda_rasterizer/forward.cu
39
+ submodules/gaussian-importance/cuda_rasterizer/rasterizer_impl.cu
33
40
  submodules/simple-knn/ext.cpp
34
41
  submodules/simple-knn/simple_knn.cu
35
42
  submodules/simple-knn/spatial.cu
36
- submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py
43
+ submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py
44
+ submodules/gaussian-importance/diff_gaussian_rasterization/__init__.py
@@ -40,6 +40,17 @@ rasterizor_packages = {
40
40
  'reduced_3dgs.simple_knn': 'submodules/simple-knn/simple_knn',
41
41
  }
42
42
 
43
+ importance_root = "submodules/gaussian-importance"
44
+ importance_sources = [
45
+ "cuda_rasterizer/rasterizer_impl.cu",
46
+ "cuda_rasterizer/forward.cu",
47
+ "cuda_rasterizer/backward.cu",
48
+ "rasterize_points.cu",
49
+ "ext.cpp"]
50
+ importance_packages = {
51
+ 'reduced_3dgs.pruning.importance.diff_gaussian_rasterization': 'submodules/gaussian-importance/diff_gaussian_rasterization',
52
+ }
53
+
43
54
  cxx_compiler_flags = []
44
55
  nvcc_compiler_flags = []
45
56
 
@@ -49,7 +60,7 @@ if os.name == 'nt':
49
60
 
50
61
  setup(
51
62
  name="reduced_3dgs",
52
- version='1.8.14',
63
+ version='1.8.16',
53
64
  author='yindaheng98',
54
65
  author_email='yindaheng98@gmail.com',
55
66
  url='https://github.com/yindaheng98/reduced-3dgs',
@@ -59,10 +70,11 @@ setup(
59
70
  classifiers=[
60
71
  "Programming Language :: Python :: 3",
61
72
  ],
62
- packages=packages + list(rasterizor_packages.keys()),
73
+ packages=packages + list(rasterizor_packages.keys()) + list(importance_packages.keys()),
63
74
  package_dir={
64
75
  'reduced_3dgs': 'reduced_3dgs',
65
- **rasterizor_packages
76
+ **rasterizor_packages,
77
+ **importance_packages,
66
78
  },
67
79
  ext_modules=[
68
80
  CUDAExtension(
@@ -70,6 +82,11 @@ setup(
70
82
  sources=[os.path.join(rasterizor_root, source) for source in rasterizor_sources],
71
83
  extra_compile_args={"nvcc": nvcc_compiler_flags + ["-I" + os.path.join(os.path.abspath(rasterizor_root), "third_party/glm/")]}
72
84
  ),
85
+ CUDAExtension(
86
+ name="reduced_3dgs.pruning.importance.diff_gaussian_rasterization._C",
87
+ sources=[os.path.join(importance_root, source) for source in importance_sources],
88
+ extra_compile_args={"nvcc": nvcc_compiler_flags + ["-I" + os.path.join(os.path.abspath(importance_root), "third_party/glm/")]}
89
+ ),
73
90
  CUDAExtension(
74
91
  name="reduced_3dgs.simple_knn._C",
75
92
  sources=[os.path.join(simpleknn_root, source) for source in simpleknn_sources],
@@ -1,8 +1,27 @@
1
1
  #include "sh_culling.h"
2
- #include "../cuda_rasterizer/auxiliary.h"
3
2
  #include <cooperative_groups.h>
4
3
  namespace cg = cooperative_groups;
5
4
 
5
+ // Spherical harmonics coefficients
6
+ __device__ const float SH_C0 = 0.28209479177387814f;
7
+ __device__ const float SH_C1 = 0.4886025119029199f;
8
+ __device__ const float SH_C2[] = {
9
+ 1.0925484305920792f,
10
+ -1.0925484305920792f,
11
+ 0.31539156525252005f,
12
+ -1.0925484305920792f,
13
+ 0.5462742152960396f
14
+ };
15
+ __device__ const float SH_C3[] = {
16
+ -0.5900435899266435f,
17
+ 2.890611442640554f,
18
+ -0.4570457994644658f,
19
+ 0.3731763325901154f,
20
+ -0.4570457994644658f,
21
+ 1.445305721320277f,
22
+ -0.5900435899266435f
23
+ };
24
+
6
25
  __device__ void computeColorFromSH(const int idx, const int *degs, int max_coeffs, const glm::vec3 *means, glm::vec3 campos, const float *shs, glm::vec3 *out_colours)
7
26
  {
8
27
  // The implementation is loosely based on code for