reduced-3dgs 1.10.2__tar.gz → 1.10.4__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.
Files changed (48) hide show
  1. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/PKG-INFO +1 -1
  2. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantization/quantizer.py +30 -12
  3. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantize.py +1 -0
  4. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs.egg-info/PKG-INFO +1 -1
  5. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/setup.py +1 -1
  6. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/LICENSE.md +0 -0
  7. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/README.md +0 -0
  8. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/__init__.py +0 -0
  9. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/combinations.py +0 -0
  10. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/importance/__init__.py +0 -0
  11. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/importance/combinations.py +0 -0
  12. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/importance/trainer.py +0 -0
  13. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/prepare.py +0 -0
  14. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/pruning/__init__.py +0 -0
  15. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/pruning/combinations.py +0 -0
  16. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/pruning/trainer.py +0 -0
  17. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantization/__init__.py +0 -0
  18. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantization/abc.py +0 -0
  19. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantization/exclude_zeros.py +0 -0
  20. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantization/wrapper.py +0 -0
  21. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/shculling/__init__.py +0 -0
  22. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/shculling/gaussian_model.py +0 -0
  23. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/shculling/trainer.py +0 -0
  24. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/train.py +0 -0
  25. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs.egg-info/SOURCES.txt +0 -0
  26. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs.egg-info/dependency_links.txt +0 -0
  27. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs.egg-info/requires.txt +0 -0
  28. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs.egg-info/top_level.txt +0 -0
  29. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/setup.cfg +0 -0
  30. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/cuda_rasterizer/backward.cu +0 -0
  31. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/cuda_rasterizer/forward.cu +0 -0
  32. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/cuda_rasterizer/rasterizer_impl.cu +0 -0
  33. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py +0 -0
  34. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/ext.cpp +0 -0
  35. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/rasterize_points.cu +0 -0
  36. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/reduced_3dgs/kmeans.cu +0 -0
  37. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/reduced_3dgs/redundancy_score.cu +0 -0
  38. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/reduced_3dgs/sh_culling.cu +0 -0
  39. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/reduced_3dgs.cu +0 -0
  40. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/cuda_rasterizer/backward.cu +0 -0
  41. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/cuda_rasterizer/forward.cu +0 -0
  42. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/cuda_rasterizer/rasterizer_impl.cu +0 -0
  43. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/diff_gaussian_rasterization/__init__.py +0 -0
  44. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/ext.cpp +0 -0
  45. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/rasterize_points.cu +0 -0
  46. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/simple-knn/ext.cpp +0 -0
  47. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/simple-knn/simple_knn.cu +0 -0
  48. {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/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.10.2
3
+ Version: 1.10.4
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
@@ -206,8 +206,7 @@ class VectorQuantizer(AbstractQuantizer):
206
206
  ids_dict = self.find_nearest_cluster_id(model, self._codebook_dict)
207
207
  return ids_dict, codebook_dict
208
208
 
209
- def save_quantized(self, model: GaussianModel, ply_path: str):
210
- ids_dict, codebook_dict = self.quantize(model, update_codebook=False)
209
+ def ply_dtype(self, max_sh_degree: int):
211
210
  dtype_full = [
212
211
  ('x', 'f4'), ('y', 'f4'), ('z', 'f4'),
213
212
  ('nx', 'f4'), ('ny', 'f4'), ('nz', 'f4'),
@@ -217,13 +216,16 @@ class VectorQuantizer(AbstractQuantizer):
217
216
  ('scale', self.force_code_dtype or compute_uint_dtype(self.num_clusters_scaling)),
218
217
  ('f_dc', self.force_code_dtype or compute_uint_dtype(self.num_clusters_features_dc)),
219
218
  ]
220
- for sh_degree in range(model.max_sh_degree):
219
+ for sh_degree in range(max_sh_degree):
221
220
  force_code_dtype = self.force_code_dtype or compute_uint_dtype(self.num_clusters_features_rest[sh_degree])
222
221
  dtype_full.extend([
223
222
  (f'f_rest_{sh_degree}_0', force_code_dtype),
224
223
  (f'f_rest_{sh_degree}_1', force_code_dtype),
225
224
  (f'f_rest_{sh_degree}_2', force_code_dtype),
226
225
  ])
226
+ return dtype_full
227
+
228
+ def ply_data(self, model: GaussianModel, ids_dict: Dict[str, torch.Tensor]):
227
229
  data_full = [
228
230
  *np.array_split(model._xyz.detach().cpu().numpy(), 3, axis=1),
229
231
  *np.array_split(torch.zeros_like(model._xyz).detach().cpu().numpy(), 3, axis=1),
@@ -236,6 +238,12 @@ class VectorQuantizer(AbstractQuantizer):
236
238
  for sh_degree in range(model.max_sh_degree):
237
239
  features_rest = ids_dict[f'features_rest_{sh_degree}'].cpu().numpy()
238
240
  data_full.extend(np.array_split(features_rest, 3, axis=1))
241
+ return data_full
242
+
243
+ def save_quantized(self, model: GaussianModel, ply_path: str):
244
+ ids_dict, codebook_dict = self.quantize(model, update_codebook=False)
245
+ dtype_full = self.ply_dtype(model.max_sh_degree)
246
+ data_full = self.ply_data(model, ids_dict)
239
247
 
240
248
  elements = np.rec.fromarrays([data.squeeze(-1) for data in data_full], dtype=dtype_full)
241
249
  el = PlyElement.describe(elements, 'vertex')
@@ -254,36 +262,46 @@ class VectorQuantizer(AbstractQuantizer):
254
262
 
255
263
  PlyData([el, *cb]).write(ply_path)
256
264
 
257
- def load_quantized(self, model: GaussianModel, ply_path: str) -> GaussianModel:
258
- plydata = PlyData.read(ply_path)
259
-
265
+ def parse_ids(self, plydata: PlyData, max_sh_degree: int, device: torch.device) -> Dict[str, torch.Tensor]:
260
266
  ids_dict = {}
261
267
  elements = plydata['vertex']
262
- kwargs = dict(dtype=torch.long, device=model._xyz.device)
268
+ kwargs = dict(dtype=torch.long, device=device)
263
269
  ids_dict["rotation_re"] = torch.tensor(elements["rot_re"].copy(), **kwargs)
264
270
  ids_dict["rotation_im"] = torch.tensor(elements["rot_im"].copy(), **kwargs)
265
271
  ids_dict["opacity"] = torch.tensor(elements["opacity"].copy(), **kwargs)
266
272
  ids_dict["scaling"] = torch.tensor(elements["scale"].copy(), **kwargs)
267
273
  ids_dict["features_dc"] = torch.tensor(elements["f_dc"].copy(), **kwargs).unsqueeze(-1)
268
- for sh_degree in range(model.max_sh_degree):
274
+ for sh_degree in range(max_sh_degree):
269
275
  ids_dict[f'features_rest_{sh_degree}'] = torch.tensor(np.stack([elements[f'f_rest_{sh_degree}_{ch}'] for ch in range(3)], axis=1), **kwargs)
276
+ return ids_dict
270
277
 
278
+ def parse_codebook(self, plydata: PlyData, max_sh_degree: int, device: torch.device) -> Dict[str, torch.Tensor]:
271
279
  codebook_dict = {}
272
- kwargs = dict(dtype=torch.float32, device=model._xyz.device)
280
+ kwargs = dict(dtype=torch.float32, device=device)
273
281
  codebook_dict["rotation_re"] = torch.tensor(plydata["codebook_rot_re"]["rot_re"], **kwargs).unsqueeze(-1)
274
282
  codebook_dict["rotation_im"] = torch.tensor(np.stack([plydata["codebook_rot_im"][f'rot_im_{ch}'] for ch in range(3)], axis=1), **kwargs)
275
283
  codebook_dict["opacity"] = torch.tensor(plydata["codebook_opacity"]["opacity"], **kwargs).unsqueeze(-1)
276
284
  codebook_dict["scaling"] = torch.tensor(np.stack([plydata["codebook_scaling"][f'scaling_{ch}'] for ch in range(3)], axis=1), **kwargs)
277
285
  codebook_dict["features_dc"] = torch.tensor(np.stack([plydata["codebook_f_dc"][f'f_dc_{ch}'] for ch in range(3)], axis=1), **kwargs)
278
- for sh_degree in range(model.max_sh_degree):
286
+ for sh_degree in range(max_sh_degree):
279
287
  n_channels = (sh_degree + 2) ** 2 - (sh_degree + 1) ** 2
280
288
  codebook_dict[f'features_rest_{sh_degree}'] = torch.tensor(np.stack([plydata[f"codebook_f_rest_{sh_degree}"][f'f_rest_{sh_degree}_{ch}'] for ch in range(n_channels)], axis=1), **kwargs)
289
+ return codebook_dict
281
290
 
282
- self._codebook_dict = codebook_dict
283
-
291
+ def parse_xyz(self, plydata: PlyData, device: torch.device) -> torch.Tensor:
292
+ elements = plydata['vertex']
293
+ kwargs = dict(dtype=torch.float32, device=device)
284
294
  xyz = torch.stack([
285
295
  torch.tensor(elements["x"].copy(), **kwargs),
286
296
  torch.tensor(elements["y"].copy(), **kwargs),
287
297
  torch.tensor(elements["z"].copy(), **kwargs),
288
298
  ], dim=1)
299
+ return xyz
300
+
301
+ def load_quantized(self, model: GaussianModel, ply_path: str) -> GaussianModel:
302
+ plydata = PlyData.read(ply_path)
303
+ ids_dict = self.parse_ids(plydata, model.max_sh_degree, model._xyz.device)
304
+ codebook_dict = self.parse_codebook(plydata, model.max_sh_degree, model._xyz.device)
305
+ xyz = self.parse_xyz(plydata, model._xyz.device)
306
+ self._codebook_dict = codebook_dict
289
307
  return self.dequantize(model, ids_dict, codebook_dict, xyz=xyz, replace=True)
@@ -13,6 +13,7 @@ def copy_not_exists(source, destination):
13
13
 
14
14
 
15
15
  def quantize(source, destination, iteration, sh_degree, device, **kwargs):
16
+ os.makedirs(destination, exist_ok=True)
16
17
  copy_not_exists(os.path.join(source, "cfg_args"), os.path.join(destination, "cfg_args"))
17
18
  copy_not_exists(os.path.join(source, "cameras.json"), os.path.join(destination, "cameras.json"))
18
19
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reduced_3dgs
3
- Version: 1.10.2
3
+ Version: 1.10.4
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
@@ -60,7 +60,7 @@ if os.name == 'nt':
60
60
 
61
61
  setup(
62
62
  name="reduced_3dgs",
63
- version='1.10.2',
63
+ version='1.10.4',
64
64
  author='yindaheng98',
65
65
  author_email='yindaheng98@gmail.com',
66
66
  url='https://github.com/yindaheng98/reduced-3dgs',
File without changes
File without changes
File without changes