Skip to content

Commit d4283b4

Browse files
Merge pull request #58 from autonomousvision/dev
Speedup by merging repeated computation
2 parents a968d35 + 8dd817e commit d4283b4

9 files changed

Lines changed: 311 additions & 353 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
</p>
2222

2323
<p align="center">
24-
Gaussian Opacity Fields (GOF) enables geometry extraction with 3D Gaussians directly by indentifying its level set. Our regularization improves surface reconstruction and we utilize Marching Tetrahedra for compact and adaptive mesh extraction.</p>
24+
Gaussian Opacity Fields (GOF) enables geometry extraction with 3D Gaussians directly by indentifying its level set. Our regularization improves surface reconstruction and we utilize Marching Tetrahedra for adaptive and compact mesh extraction.</p>
2525
<br>
2626

27+
# Updates
28+
29+
* **[2024.06.10]**: 🔥 Improve the training speed by 2x with [merged operations](https://github.com/autonomousvision/gaussian-opacity-fields/pull/58). 6 scenes in TNT dataset can be trained in ~24 mins and the bicycle scene in the Mip-NeRF 360 dataset can be trained in ~45 mins. Please pull the latest code and reinstall with `pip install submodules/diff-gaussian-rasterization` to use it.
2730

2831
# Installation
2932
Clone the repository and create an anaconda environment using

evaluate_dtu_mesh.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ def cull_mesh(cameras, mesh):
130130
mesh.update_faces(face_mask)
131131

132132
# Taking the biggest connected component
133-
print("Taking the biggest connected component")
134-
components = mesh.split(only_watertight=False)
135-
areas = np.array([c.area for c in components], dtype=np.float32)
136-
mesh_clean = components[areas.argmax()]
137-
138-
return mesh_clean
133+
# print("Taking the biggest connected component")
134+
# components = mesh.split(only_watertight=False)
135+
# areas = np.array([c.area for c in components], dtype=np.float32)
136+
# mesh_clean = components[areas.argmax()]
139137

138+
# return mesh_clean
139+
return mesh
140140

141141
def evaluate_mesh(dataset : ModelParams, iteration : int, DTU_PATH : str):
142142

scene/gaussian_model.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,20 @@ def get_view2gaussian(self, viewmatrix):
196196

197197
# transpose view2gaussian to match glm in CUDA code
198198
V2G = V2G.transpose(2, 1).contiguous()
199-
return V2G
199+
200+
# precompute results to reduce computation and IO
201+
scales = self.get_scaling_with_3D_filter
202+
S_inv_square = 1.0 / (scales ** 2)
203+
R = V2G[:, :3, :3].transpose(1, 2)
204+
t2 = V2G[:, 3:, :3]
205+
206+
C = torch.sum((t2 ** 2) * S_inv_square[:, None, :], dim=2)
207+
S_inv_square_R = S_inv_square[:, :, None] * R
208+
B = t2 @ S_inv_square_R
209+
Sigma = R.transpose(1, 2) @ S_inv_square_R
210+
merged = torch.cat([Sigma[:, :, 0], Sigma[:, 1:, 1], Sigma[:, 2:, 2], B.squeeze(), C], dim=1)
211+
212+
return merged
200213

201214
@torch.no_grad()
202215
def compute_3D_filter(self, cameras):

scripts/show_nerfsynthetic.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import os
2+
import json
3+
import numpy as np
4+
import trimesh
5+
6+
scenes = ["chair", "drums", "ficus", "hotdog", "lego", "materials", "mic", "ship"]
7+
8+
output_dirs = ["exp_nerf_synthetic/release"]
9+
10+
results = []
11+
for scene in scenes:
12+
print(scene,)
13+
for output in output_dirs:
14+
json_file = f"{output}/{scene}/results.json"
15+
data = json.load(open(json_file))
16+
data = data['ours_30000'] if 'ours_30000' in data else data['ours_7000']
17+
18+
iteration = "30K iter: "
19+
point_cloud_file = f"{output}/{scene}/point_cloud/iteration_30000/point_cloud.ply"
20+
if not os.path.exists(point_cloud_file):
21+
point_cloud_file = f"{output}/{scene}/point_cloud/iteration_7000/point_cloud.ply"
22+
iteration = "7K iter: "
23+
print(iteration, data.values(), trimesh.load(point_cloud_file).vertices.shape)
24+
results.append(data['PSNR'])
25+
26+
results = np.array(results).reshape(8, -1)
27+
28+
print("===================")
29+
print("PSNR:")
30+
print(results)
31+
print("mean:")
32+
print(results.mean(axis=0))
33+

0 commit comments

Comments
 (0)