reduced-3dgs 1.10.4__cp311-cp311-win_amd64.whl → 1.10.12__cp311-cp311-win_amd64.whl

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.
@@ -97,11 +97,17 @@ def BaseFullPrunerInDensifyTrainer(
97
97
 
98
98
 
99
99
  def DepthFullPruningTrainer(model: GaussianModel, scene_extent: float, dataset: TrainableCameraDataset, *args, **kwargs):
100
- return DepthTrainerWrapper(BaseFullPruningTrainer, model, scene_extent, *args, dataset=dataset, **kwargs)
100
+ return DepthTrainerWrapper(
101
+ BaseFullPruningTrainer,
102
+ model, scene_extent, dataset,
103
+ *args, **kwargs)
101
104
 
102
105
 
103
106
  def DepthFullPrunerInDensifyTrainer(model: GaussianModel, scene_extent: float, dataset: TrainableCameraDataset, *args, **kwargs):
104
- return DepthTrainerWrapper(BaseFullPrunerInDensifyTrainer, model, scene_extent, *args, dataset=dataset, **kwargs)
107
+ return DepthTrainerWrapper(
108
+ BaseFullPrunerInDensifyTrainer,
109
+ model, scene_extent, dataset,
110
+ *args, **kwargs)
105
111
 
106
112
 
107
113
  def OpacityResetPruningTrainer(
@@ -52,11 +52,17 @@ def BaseImportancePrunerInDensifyTrainer(
52
52
 
53
53
 
54
54
  def DepthImportancePruningTrainer(model: GaussianModel, scene_extent: float, dataset: TrainableCameraDataset, *args, **kwargs):
55
- return DepthTrainerWrapper(BaseImportancePruningTrainer, model, scene_extent, *args, dataset=dataset, **kwargs)
55
+ return DepthTrainerWrapper(
56
+ BaseImportancePruningTrainer,
57
+ model, scene_extent, dataset,
58
+ *args, **kwargs)
56
59
 
57
60
 
58
61
  def DepthImportancePrunerInDensifyTrainer(model: GaussianModel, scene_extent: float, dataset: TrainableCameraDataset, *args, **kwargs):
59
- return DepthTrainerWrapper(BaseImportancePrunerInDensifyTrainer, model, scene_extent, *args, dataset=dataset, **kwargs)
62
+ return DepthTrainerWrapper(
63
+ BaseImportancePrunerInDensifyTrainer,
64
+ model, scene_extent, dataset,
65
+ *args, **kwargs)
60
66
 
61
67
 
62
68
  ImportancePruningTrainer = DepthImportancePruningTrainer
@@ -54,11 +54,17 @@ def BasePrunerInDensifyTrainer(
54
54
 
55
55
 
56
56
  def DepthPruningTrainer(model: GaussianModel, scene_extent: float, dataset: TrainableCameraDataset, *args, **kwargs):
57
- return DepthTrainerWrapper(BasePruningTrainer, model, scene_extent, *args, dataset=dataset, **kwargs)
57
+ return DepthTrainerWrapper(
58
+ BasePruningTrainer,
59
+ model, scene_extent, dataset,
60
+ *args, **kwargs)
58
61
 
59
62
 
60
63
  def DepthPrunerInDensifyTrainer(model: GaussianModel, scene_extent: float, dataset: TrainableCameraDataset, *args, **kwargs):
61
- return DepthTrainerWrapper(BasePrunerInDensifyTrainer, model, scene_extent, *args, dataset=dataset, **kwargs)
64
+ return DepthTrainerWrapper(
65
+ BasePrunerInDensifyTrainer,
66
+ model, scene_extent, dataset,
67
+ *args, **kwargs)
62
68
 
63
69
 
64
70
  PruningTrainer = DepthPruningTrainer
@@ -4,7 +4,15 @@ from typing import Dict, Tuple
4
4
  import torch
5
5
  import torch.nn as nn
6
6
  import numpy as np
7
- from sklearn.cluster import MiniBatchKMeans as KMeans
7
+ try:
8
+ from cuml.cluster import KMeans
9
+ kmeans_init = 'k-means||'
10
+ except ImportError:
11
+ print("Cuml not found, using sklearn's MiniBatchKMeans for quantization.")
12
+ from sklearn.cluster import MiniBatchKMeans
13
+ from functools import partial
14
+ KMeans = partial(MiniBatchKMeans, batch_size=256 * os.cpu_count())
15
+ kmeans_init = 'k-means++'
8
16
  from gaussian_splatting import GaussianModel
9
17
  from plyfile import PlyData, PlyElement
10
18
  import numpy as np
@@ -65,9 +73,8 @@ class VectorQuantizer(AbstractQuantizer):
65
73
  def generate_codebook(self, values: torch.Tensor, num_clusters, init_codebook=None):
66
74
  kmeans = KMeans(
67
75
  n_clusters=num_clusters, tol=self.tol, max_iter=self.max_iter,
68
- init='k-means++' if init_codebook is None else init_codebook.cpu().numpy(),
69
- random_state=0, n_init="auto", verbose=0,
70
- batch_size=256 * os.cpu_count()
76
+ init=kmeans_init if init_codebook is None else init_codebook.cpu().numpy(),
77
+ random_state=0, n_init="auto", verbose=1,
71
78
  )
72
79
  ids = torch.tensor(kmeans.fit_predict(values.cpu().numpy()), device=values.device)
73
80
  centers = torch.tensor(kmeans.cluster_centers_, dtype=values.dtype, device=values.device)
reduced_3dgs/train.py CHANGED
@@ -14,8 +14,12 @@ from reduced_3dgs.quantization import AbstractQuantizer
14
14
  from reduced_3dgs.prepare import modes, prepare_gaussians, prepare_trainer
15
15
 
16
16
 
17
- def prepare_training(sh_degree: int, source: str, device: str, mode: str, trainable_camera: bool = False, load_ply: str = None, load_camera: str = None, load_depth=False, with_scale_reg=False, quantize: bool = False, load_quantized: str = None, configs={}):
18
- dataset = prepare_dataset(source=source, device=device, trainable_camera=trainable_camera, load_camera=load_camera, load_depth=load_depth)
17
+ def prepare_training(
18
+ sh_degree: int, source: str, device: str, mode: str,
19
+ trainable_camera: bool = False, load_ply: str = None, load_camera: str = None,
20
+ load_mask=True, load_depth=True,
21
+ with_scale_reg=False, quantize: bool = False, load_quantized: str = None, configs={}):
22
+ dataset = prepare_dataset(source=source, device=device, trainable_camera=trainable_camera, load_camera=load_camera, load_mask=load_mask, load_depth=load_depth)
19
23
  gaussians = prepare_gaussians(sh_degree=sh_degree, source=source, device=device, trainable_camera=trainable_camera, load_ply=load_ply)
20
24
  trainer, quantizer = prepare_trainer(gaussians=gaussians, dataset=dataset, mode=mode, with_scale_reg=with_scale_reg, quantize=quantize, load_quantized=load_quantized, configs=configs)
21
25
  return dataset, gaussians, trainer, quantizer
@@ -23,26 +27,39 @@ def prepare_training(sh_degree: int, source: str, device: str, mode: str, traina
23
27
 
24
28
  def training(dataset: CameraDataset, gaussians: GaussianModel, trainer: AbstractTrainer, quantizer: AbstractQuantizer, destination: str, iteration: int, save_iterations: List[int], device: str, empty_cache_every_step=False):
25
29
  shutil.rmtree(os.path.join(destination, "point_cloud"), ignore_errors=True) # remove the previous point cloud
26
- pbar = tqdm(range(1, iteration+1))
30
+ pbar = tqdm(range(1, iteration+1), dynamic_ncols=True, desc="Training")
27
31
  epoch = list(range(len(dataset)))
28
32
  epoch_psnr = torch.empty(3, 0, device=device)
33
+ epoch_maskpsnr = torch.empty(3, 0, device=device)
29
34
  ema_loss_for_log = 0.0
30
35
  avg_psnr_for_log = 0.0
36
+ avg_maskpsnr_for_log = 0.0
31
37
  for step in pbar:
32
38
  epoch_idx = step % len(dataset)
33
39
  if epoch_idx == 0:
34
40
  avg_psnr_for_log = epoch_psnr.mean().item()
41
+ avg_maskpsnr_for_log = epoch_maskpsnr.mean().item()
35
42
  epoch_psnr = torch.empty(3, 0, device=device)
43
+ epoch_maskpsnr = torch.empty(3, 0, device=device)
36
44
  random.shuffle(epoch)
37
45
  idx = epoch[epoch_idx]
38
46
  loss, out = trainer.step(dataset[idx])
39
47
  if empty_cache_every_step:
40
48
  torch.cuda.empty_cache()
41
49
  with torch.no_grad():
50
+ ground_truth_image = dataset[idx].ground_truth_image
51
+ rendered_image = out["render"]
52
+ epoch_psnr = torch.concat([epoch_psnr, psnr(rendered_image, ground_truth_image)], dim=1)
53
+ if dataset[idx].ground_truth_image_mask is not None:
54
+ ground_truth_maskimage = ground_truth_image * dataset[idx].ground_truth_image_mask
55
+ rendered_maskimage = rendered_image * dataset[idx].ground_truth_image_mask
56
+ epoch_maskpsnr = torch.concat([epoch_maskpsnr, psnr(rendered_maskimage, ground_truth_maskimage)], dim=1)
42
57
  ema_loss_for_log = 0.4 * loss.item() + 0.6 * ema_loss_for_log
43
- epoch_psnr = torch.concat([epoch_psnr, psnr(out["render"], dataset[idx].ground_truth_image)], dim=1)
44
58
  if step % 10 == 0:
45
- pbar.set_postfix({'epoch': step // len(dataset), 'loss': ema_loss_for_log, 'psnr': avg_psnr_for_log, 'n': gaussians._xyz.shape[0]})
59
+ postfix = {'epoch': step // len(dataset), 'loss': ema_loss_for_log, 'psnr': avg_psnr_for_log, 'n': gaussians._xyz.shape[0]}
60
+ if avg_maskpsnr_for_log > 0:
61
+ postfix['psnr (mask)'] = avg_maskpsnr_for_log
62
+ pbar.set_postfix(postfix)
46
63
  if step in save_iterations:
47
64
  save_path = os.path.join(destination, "point_cloud", "iteration_" + str(step))
48
65
  os.makedirs(save_path, exist_ok=True)
@@ -68,6 +85,7 @@ if __name__ == "__main__":
68
85
  parser.add_argument("-l", "--load_ply", default=None, type=str)
69
86
  parser.add_argument("--load_camera", default=None, type=str)
70
87
  parser.add_argument("--quantize", action='store_true')
88
+ parser.add_argument("--no_image_mask", action="store_true")
71
89
  parser.add_argument("--no_depth_data", action='store_true')
72
90
  parser.add_argument("--with_scale_reg", action="store_true")
73
91
  parser.add_argument("--load_quantized", default=None, type=str)
@@ -83,7 +101,9 @@ if __name__ == "__main__":
83
101
  configs = {o.split("=", 1)[0]: eval(o.split("=", 1)[1]) for o in args.option}
84
102
  dataset, gaussians, trainer, quantizer = prepare_training(
85
103
  sh_degree=args.sh_degree, source=args.source, device=args.device, mode=args.mode, trainable_camera="camera" in args.mode,
86
- load_ply=args.load_ply, load_camera=args.load_camera, load_depth=not args.no_depth_data, with_scale_reg=args.with_scale_reg,
104
+ load_ply=args.load_ply, load_camera=args.load_camera,
105
+ load_mask=not args.no_image_mask, load_depth=not args.no_depth_data,
106
+ with_scale_reg=args.with_scale_reg,
87
107
  quantize=args.quantize, load_quantized=args.load_quantized, configs=configs)
88
108
  dataset.save_cameras(os.path.join(args.destination, "cameras.json"))
89
109
  torch.cuda.empty_cache()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reduced_3dgs
3
- Version: 1.10.4
3
+ Version: 1.10.12
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
@@ -8,13 +8,8 @@ Author-email: yindaheng98@gmail.com
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE.md
11
- Requires-Dist: tqdm
12
- Requires-Dist: plyfile
13
- Requires-Dist: scikit-learn
14
- Requires-Dist: torch
15
- Requires-Dist: torchvision
16
- Requires-Dist: numpy
17
11
  Requires-Dist: gaussian-splatting
12
+ Requires-Dist: scikit-learn
18
13
  Dynamic: author
19
14
  Dynamic: author-email
20
15
  Dynamic: classifier
@@ -40,47 +35,35 @@ This repository contains the **refactored Python code for [Reduced-3DGS](https:/
40
35
 
41
36
  * [Pytorch](https://pytorch.org/) (v2.4 or higher recommended)
42
37
  * [CUDA Toolkit](https://developer.nvidia.com/cuda-12-4-0-download-archive) (12.4 recommended, should match with PyTorch version)
38
+ * (Optional) [cuML](https://github.com/rapidsai/cuml) for faster vector quantization
43
39
 
44
- ## Install (PyPI)
45
-
40
+ (Optional) If you have trouble with [`gaussian-splatting`](https://github.com/yindaheng98/gaussian-splatting), try to install it from source:
46
41
  ```sh
47
- pip install --upgrade reduced-3dgs
42
+ pip install wheel setuptools
43
+ pip install --upgrade git+https://github.com/yindaheng98/gaussian-splatting.git@master --no-build-isolation
48
44
  ```
49
45
 
50
- ## Install (Build from source)
51
-
52
- ```sh
53
- pip install --upgrade git+https://github.com/yindaheng98/reduced-3dgs.git@main
54
- ```
55
- If you have trouble with [`gaussian-splatting`](https://github.com/yindaheng98/gaussian-splatting), you can install it from source:
56
- ```sh
57
- pip install --upgrade git+https://github.com/yindaheng98/gaussian-splatting.git@master
58
- ```
46
+ ## PyPI Install
59
47
 
60
- ## Install (Development)
61
-
62
- Install [`gaussian-splatting`](https://github.com/yindaheng98/gaussian-splatting).
63
- You can download the wheel from [PyPI](https://pypi.org/project/gaussian-splatting/):
64
48
  ```shell
65
- pip install --upgrade gaussian-splatting
49
+ pip install --upgrade reduced-3dgs
66
50
  ```
67
- Alternatively, install the latest version from the source:
68
- ```sh
69
- pip install --upgrade git+https://github.com/yindaheng98/gaussian-splatting.git@master
51
+ or
52
+ build latest from source:
53
+ ```shell
54
+ pip install wheel setuptools
55
+ pip install --upgrade git+https://github.com/yindaheng98/reduced-3dgs.git@main --no-build-isolation
70
56
  ```
71
57
 
58
+ ### Development Install
59
+
72
60
  ```shell
73
61
  git clone --recursive https://github.com/yindaheng98/reduced-3dgs
74
62
  cd reduced-3dgs
75
- pip install tqdm plyfile scikit-learn numpy tifffile triton xformers
63
+ pip install scikit-learn
76
64
  pip install --target . --upgrade --no-deps .
77
65
  ```
78
66
 
79
- (Optional) If you prefer not to install `gaussian-splatting` in your environment, you can install it in your `reduced-3dgs` directory:
80
- ```sh
81
- pip install --target . --no-deps --upgrade git+https://github.com/yindaheng98/gaussian-splatting.git@master
82
- ```
83
-
84
67
  ## Quick Start
85
68
 
86
69
  1. Download the dataset (T&T+DB COLMAP dataset, size 650MB):
@@ -1,29 +1,29 @@
1
1
  reduced_3dgs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- reduced_3dgs/combinations.py,sha256=k4ErxpAscCqJMtVXZ29KGQjw2VoZMV0W3V4u3nj0e-Y,9401
2
+ reduced_3dgs/combinations.py,sha256=dRrtTIQLggUP22Olp0DVSlD0C8YDgnrpTlrCcGZyWM0,9441
3
3
  reduced_3dgs/prepare.py,sha256=MFUUckRHKfgcva4ZOBxfPFyE95N-OlCQLplpmEPuzOk,4440
4
4
  reduced_3dgs/quantize.py,sha256=BVqBb2tQgiP3hap5-OByD8VELtJJGfEeFzaVFyzCJZU,2572
5
- reduced_3dgs/train.py,sha256=yRQPQv-hTOBQN-tqGHYs2aIZ0AbWq158CXpthYN2cfw,5666
6
- reduced_3dgs/diff_gaussian_rasterization/_C.cp311-win_amd64.pyd,sha256=z_fsa8uGn_5Q4gGNBlhZY0dMwbc8u-uNwe_8qecm6J8,1632256
5
+ reduced_3dgs/train.py,sha256=P9GCoEVl_VGldKuA3ycj1nea5rTc3xqu_f02a8oe-Lc,6734
6
+ reduced_3dgs/diff_gaussian_rasterization/_C.cp311-win_amd64.pyd,sha256=aWFuGgyzyWa0cjbPxVD-hytfzFy7OoBp2cmWhUjlxCQ,1623552
7
7
  reduced_3dgs/diff_gaussian_rasterization/__init__.py,sha256=oV6JjTc-50MscX4XHeIWSgLr3l8Y25knBIs-0gRbJr4,7932
8
8
  reduced_3dgs/importance/__init__.py,sha256=neJsbY5cLikEGBQGdR4MjwCQ5VWVikT1357DwL0EtWU,289
9
- reduced_3dgs/importance/combinations.py,sha256=eAdykeTdvRGCHxskjILQnZVaqQVvwC-0wMxdgYMeeDs,2922
9
+ reduced_3dgs/importance/combinations.py,sha256=F9IYDZ6iquZw5Djn2An88dlp2MUGieAyuZyVaDZdSts,2962
10
10
  reduced_3dgs/importance/trainer.py,sha256=Sj4ORvoYtFT7z3hifzFZDfhFyqumHraXyk3vMVtk0AU,12661
11
- reduced_3dgs/importance/diff_gaussian_rasterization/_C.cp311-win_amd64.pyd,sha256=sKkkpqtRlM-FWeyXzpqdQ_XtmEF_7OYEoAvR8ab_uws,1315840
11
+ reduced_3dgs/importance/diff_gaussian_rasterization/_C.cp311-win_amd64.pyd,sha256=F8XFzTme9bbxV3mo_q9aW_O-UzCdLnb0Hb_kjyLE0oA,1309696
12
12
  reduced_3dgs/importance/diff_gaussian_rasterization/__init__.py,sha256=Tix8auyXBb_QFQtXrV3sLE9kdnl5zgHH0BbqcFzDp84,12850
13
13
  reduced_3dgs/pruning/__init__.py,sha256=E_YxJ9cDV_B6EJbYUBEcuRYMIht_C72rI1VJUXFCLpM,201
14
- reduced_3dgs/pruning/combinations.py,sha256=QhXt2C7pTXhwzp9hPL9dVdiQzz0cUQpm5qljqytPEsM,2345
14
+ reduced_3dgs/pruning/combinations.py,sha256=xO39d08DEsDnKI5np_1xQ4H29O486Q_cThLfWhlH810,2385
15
15
  reduced_3dgs/pruning/trainer.py,sha256=JJml-uYfDfUpbsjRNZbIvnUYYslVgFXkhejbkYSo0s4,6542
16
16
  reduced_3dgs/quantization/__init__.py,sha256=1z1xMn3yj9u7cR9JizGrI3WSyIES_Tqq6oDquvglSeo,225
17
17
  reduced_3dgs/quantization/abc.py,sha256=rsi8HFRwQCltWTYiJ3BpygtQDT7hK6J01jKMOboOY8w,1910
18
18
  reduced_3dgs/quantization/exclude_zeros.py,sha256=fKSgjHous4OpdI6mQi9z23if9jnbB79w2jChpxkCJWw,2381
19
- reduced_3dgs/quantization/quantizer.py,sha256=lsaJ4yjxquC9XCDZPTGIKe8EgHAEwmVw9rt73oezjmc,17686
19
+ reduced_3dgs/quantization/quantizer.py,sha256=2myyBsYPGbzjZhjpKnYMYcvk6INqeds7wRdBRbIPki4,17948
20
20
  reduced_3dgs/quantization/wrapper.py,sha256=cyXqfJgo9b3fS7DYXxOk5LmQudvrEhweOebFsjRnXiQ,2549
21
21
  reduced_3dgs/shculling/__init__.py,sha256=nP2BejDCUdCmJNRbg0hfhHREO6jyZXwIcRiw6ttVgqo,149
22
22
  reduced_3dgs/shculling/gaussian_model.py,sha256=f8QWaL09vaV9Tcf6Dngjg_Fmk1wTQPAjWhuhI_N02Y8,2877
23
23
  reduced_3dgs/shculling/trainer.py,sha256=9hwR77djhZpyf-URhwKHjnLbe0ZAOS-DIw58RzkcHXQ,6369
24
- reduced_3dgs/simple_knn/_C.cp311-win_amd64.pyd,sha256=cDeScla9Mn6aDP_HNHhIIiFCwMUL78XtOid7PgOQ2bA,1263616
25
- reduced_3dgs-1.10.4.dist-info/licenses/LICENSE.md,sha256=LQ4_LAqlncGkg_mQy5ykMAFtQDSPB0eKmIEtBut0yjw,4916
26
- reduced_3dgs-1.10.4.dist-info/METADATA,sha256=TfBJNYmRSs23HhMOj15mrTFzryN015ZgGTeqUMKza7w,13015
27
- reduced_3dgs-1.10.4.dist-info/WHEEL,sha256=JLOMsP7F5qtkAkINx5UnzbFguf8CqZeraV8o04b0I8I,101
28
- reduced_3dgs-1.10.4.dist-info/top_level.txt,sha256=PpU5aT3-baSCdqCtTaZknoB32H93UeKCkYDkRCCZMEI,13
29
- reduced_3dgs-1.10.4.dist-info/RECORD,,
24
+ reduced_3dgs/simple_knn/_C.cp311-win_amd64.pyd,sha256=wSW7NtSfC_zKK3EieP3moJtC-WZkiXbnDzbmz-A8opA,1256448
25
+ reduced_3dgs-1.10.12.dist-info/licenses/LICENSE.md,sha256=LQ4_LAqlncGkg_mQy5ykMAFtQDSPB0eKmIEtBut0yjw,4916
26
+ reduced_3dgs-1.10.12.dist-info/METADATA,sha256=7cQgH63LmWATezhRqXDPA6ytT_Ld9mYXKppGqvR8QTw,12404
27
+ reduced_3dgs-1.10.12.dist-info/WHEEL,sha256=JLOMsP7F5qtkAkINx5UnzbFguf8CqZeraV8o04b0I8I,101
28
+ reduced_3dgs-1.10.12.dist-info/top_level.txt,sha256=PpU5aT3-baSCdqCtTaZknoB32H93UeKCkYDkRCCZMEI,13
29
+ reduced_3dgs-1.10.12.dist-info/RECORD,,