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.
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/PKG-INFO +1 -1
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantization/quantizer.py +30 -12
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantize.py +1 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs.egg-info/PKG-INFO +1 -1
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/setup.py +1 -1
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/LICENSE.md +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/README.md +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/__init__.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/combinations.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/importance/__init__.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/importance/combinations.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/importance/trainer.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/prepare.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/pruning/__init__.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/pruning/combinations.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/pruning/trainer.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantization/__init__.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantization/abc.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantization/exclude_zeros.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/quantization/wrapper.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/shculling/__init__.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/shculling/gaussian_model.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/shculling/trainer.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs/train.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs.egg-info/SOURCES.txt +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs.egg-info/dependency_links.txt +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs.egg-info/requires.txt +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/reduced_3dgs.egg-info/top_level.txt +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/setup.cfg +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/cuda_rasterizer/backward.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/cuda_rasterizer/forward.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/cuda_rasterizer/rasterizer_impl.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/ext.cpp +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/rasterize_points.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/reduced_3dgs/kmeans.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/reduced_3dgs/redundancy_score.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/reduced_3dgs/sh_culling.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/reduced_3dgs.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/cuda_rasterizer/backward.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/cuda_rasterizer/forward.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/cuda_rasterizer/rasterizer_impl.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/diff_gaussian_rasterization/__init__.py +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/ext.cpp +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/rasterize_points.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/simple-knn/ext.cpp +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/simple-knn/simple_knn.cu +0 -0
- {reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/simple-knn/spatial.cu +0 -0
|
@@ -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
|
|
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(
|
|
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
|
|
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=
|
|
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(
|
|
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=
|
|
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(
|
|
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
|
-
|
|
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
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/diff-gaussian-rasterization/reduced_3dgs.cu
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{reduced_3dgs-1.10.2 → reduced_3dgs-1.10.4}/submodules/gaussian-importance/rasterize_points.cu
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|