Spaces:
Runtime error
Runtime error
Stanislaw Szymanowicz
commited on
Commit
·
eac1356
1
Parent(s):
1fb0658
cull points
Browse files- app.py +1 -3
- utils/app_utils.py +8 -6
app.py
CHANGED
|
@@ -114,10 +114,8 @@ def main():
|
|
| 114 |
loop_out_path = os.path.join(os.path.dirname(ply_out_path), "loop.mp4")
|
| 115 |
imageio.mimsave(loop_out_path, loop_renders, fps=25)"""
|
| 116 |
# export reconstruction to ply
|
| 117 |
-
print("exporting")
|
| 118 |
export_to_obj(reconstruction_unactivated, ply_out_path)
|
| 119 |
-
|
| 120 |
-
print(os.listdir(os.path.dirname(os.path.abspath(__file__))))
|
| 121 |
return ply_out_path
|
| 122 |
|
| 123 |
with gr.Blocks() as demo:
|
|
|
|
| 114 |
loop_out_path = os.path.join(os.path.dirname(ply_out_path), "loop.mp4")
|
| 115 |
imageio.mimsave(loop_out_path, loop_renders, fps=25)"""
|
| 116 |
# export reconstruction to ply
|
|
|
|
| 117 |
export_to_obj(reconstruction_unactivated, ply_out_path)
|
| 118 |
+
|
|
|
|
| 119 |
return ply_out_path
|
| 120 |
|
| 121 |
with gr.Blocks() as demo:
|
utils/app_utils.py
CHANGED
|
@@ -158,13 +158,15 @@ def export_to_obj(reconstruction, ply_out_path):
|
|
| 158 |
assert v.shape[0] == 1, "Expected batch size to be 0"
|
| 159 |
reconstruction[k] = v[0]
|
| 160 |
|
| 161 |
-
|
|
|
|
|
|
|
| 162 |
normals = np.zeros_like(xyz)
|
| 163 |
-
f_dc = reconstruction["features_dc"].detach().transpose(1, 2).flatten(start_dim=1).contiguous().cpu().numpy()
|
| 164 |
-
f_rest = reconstruction["features_rest"].detach().transpose(1, 2).flatten(start_dim=1).contiguous().cpu().numpy()
|
| 165 |
-
opacities = reconstruction["opacity"].detach().cpu().numpy()
|
| 166 |
-
scale = reconstruction["scaling"].detach().cpu().numpy()
|
| 167 |
-
rotation = reconstruction["rotation"].detach().cpu().numpy()
|
| 168 |
|
| 169 |
dtype_full = [(attribute, 'f4') for attribute in construct_list_of_attributes()]
|
| 170 |
|
|
|
|
| 158 |
assert v.shape[0] == 1, "Expected batch size to be 0"
|
| 159 |
reconstruction[k] = v[0]
|
| 160 |
|
| 161 |
+
non_transparent_points = torch.where(reconstruction["opacity"] > 0.005)[0]
|
| 162 |
+
|
| 163 |
+
xyz = reconstruction["xyz"][non_transparent_points].detach().cpu().numpy()
|
| 164 |
normals = np.zeros_like(xyz)
|
| 165 |
+
f_dc = reconstruction["features_dc"][non_transparent_points].detach().transpose(1, 2).flatten(start_dim=1).contiguous().cpu().numpy()
|
| 166 |
+
f_rest = reconstruction["features_rest"][non_transparent_points].detach().transpose(1, 2).flatten(start_dim=1).contiguous().cpu().numpy()
|
| 167 |
+
opacities = reconstruction["opacity"][non_transparent_points].detach().cpu().numpy()
|
| 168 |
+
scale = reconstruction["scaling"][non_transparent_points].detach().cpu().numpy()
|
| 169 |
+
rotation = reconstruction["rotation"][non_transparent_points].detach().cpu().numpy()
|
| 170 |
|
| 171 |
dtype_full = [(attribute, 'f4') for attribute in construct_list_of_attributes()]
|
| 172 |
|