ostapagon commited on
Commit
c6a15a0
·
1 Parent(s): 47ee90a

Add new whls and add 3DGS tab

Browse files
app.py CHANGED
@@ -6,7 +6,7 @@ import gradio as gr
6
  import torch
7
  from mast3r.demo import get_args_parser
8
  from mast3r_demo import mast3r_demo_tab
9
- # from gs_demo import gs_demo_tab
10
 
11
  if __name__ == '__main__':
12
  # parser = get_args_parser()
@@ -27,8 +27,8 @@ if __name__ == '__main__':
27
  with gr.Tabs():
28
  with gr.Tab("MASt3R Demo"):
29
  mast3r_demo_tab()
30
- # with gr.Tab("Gaussian Splatting Demo"):
31
- # gs_demo_tab(cache_path)
32
 
33
  demo.launch(show_error=True, share=None, server_name=None, server_port=None)
34
  # demo.launch(show_error=True, share=None, server_name='0.0.0.0', server_port=5555)
 
6
  import torch
7
  from mast3r.demo import get_args_parser
8
  from mast3r_demo import mast3r_demo_tab
9
+ from gs_demo import gs_demo_tab
10
 
11
  if __name__ == '__main__':
12
  # parser = get_args_parser()
 
27
  with gr.Tabs():
28
  with gr.Tab("MASt3R Demo"):
29
  mast3r_demo_tab()
30
+ with gr.Tab("Gaussian Splatting Demo"):
31
+ gs_demo_tab(cache_path)
32
 
33
  demo.launch(show_error=True, share=None, server_name=None, server_port=None)
34
  # demo.launch(show_error=True, share=None, server_name='0.0.0.0', server_port=5555)
demo/mast3r_demo.py CHANGED
@@ -139,40 +139,40 @@ def get_3D_model_from_scene(scene, scene_state, min_conf_thr=2, as_pointcloud=Fa
139
  return _convert_scene_output_to_glb(outfile, rgbimg, pts3d, msk, focals, cams2world, as_pointcloud=as_pointcloud,
140
  transparent_cams=transparent_cams, cam_size=cam_size, silent=SILENT)
141
 
142
- # def save_colmap_scene(scene, save_dir, min_conf_thr=2, clean_depth=False):
143
- # if 'save_pointcloud_with_normals' not in globals():
144
- # sys.path.append(os.path.join(os.path.dirname(__file__), '../wild-gaussian-splatting/gaussian-splatting'))
145
- # sys.path.append(os.path.join(os.path.dirname(__file__), '../wild-gaussian-splatting/src'))
146
- # from colmap_dataset_utils import (
147
- # inv,
148
- # init_filestructure,
149
- # save_images_masks,
150
- # save_cameras,
151
- # save_imagestxt,
152
- # save_pointcloud,
153
- # save_pointcloud_with_normals
154
- # )
155
-
156
- # cam2world = scene.get_im_poses().detach().cpu().numpy()
157
- # world2cam = inv(cam2world) #
158
- # principal_points = scene.get_principal_points().detach().cpu().numpy()
159
- # focals = scene.get_focals().detach().cpu().numpy()[..., None]
160
- # imgs = np.array(scene.imgs)
161
-
162
- # pts3d, _, confs = scene.get_dense_pts3d(clean_depth=clean_depth)
163
- # pts3d = [i.detach().reshape(imgs[0].shape) for i in pts3d] #
164
-
165
- # masks = to_numpy([c > min_conf_thr for c in to_numpy(confs)])
166
-
167
- # # move
168
- # mask_images = True
169
-
170
- # save_path, images_path, masks_path, sparse_path = init_filestructure(save_dir)
171
- # save_images_masks(imgs, masks, images_path, masks_path, mask_images)
172
- # save_cameras(focals, principal_points, sparse_path, imgs_shape=imgs.shape)
173
- # save_imagestxt(world2cam, sparse_path)
174
- # save_pointcloud_with_normals(imgs, pts3d, masks, sparse_path)
175
- # return save_path
176
 
177
  @spaces.GPU(duration=10)
178
  def get_reconstructed_scene(image_size, current_scene_state,
@@ -223,10 +223,7 @@ def get_reconstructed_scene(image_size, current_scene_state,
223
  os.makedirs(base_colmapdata_dir, exist_ok=True)
224
  colmap_data_dir = get_next_dir(base_colmapdata_dir)
225
  #
226
- # save_colmap_scene(scene, colmap_data_dir, min_conf_thr, clean_depth)
227
- if 'GaussianRasterizer' not in globals():
228
- print("Importing diff_gaussian_rasterization")
229
- from diff_gaussian_rasterization import GaussianRasterizer, GaussianRasterizationSettings
230
 
231
  if current_scene_state is not None and \
232
  current_scene_state.outfile_name is not None:
@@ -269,12 +266,6 @@ def set_scenegraph_options(inputfiles, win_cyclic, refid, scenegraph_type):
269
  return win_col, winsize, win_cyclic, refid
270
 
271
 
272
- # def get_reconstructed_scene_wrapper_func(*args, **kwargs):
273
- # return get_reconstructed_scene(CACHE_PATH, MODEL, DEVICE, SILENT, *args, **kwargs)
274
-
275
- # def update_3D_model_from_scene(*args, **kwargs):
276
- # return get_3D_model_from_scene(SILENT, *args, **kwargs)
277
-
278
  def mast3r_demo_tab():
279
 
280
  if not SILENT:
 
139
  return _convert_scene_output_to_glb(outfile, rgbimg, pts3d, msk, focals, cams2world, as_pointcloud=as_pointcloud,
140
  transparent_cams=transparent_cams, cam_size=cam_size, silent=SILENT)
141
 
142
+ def save_colmap_scene(scene, save_dir, min_conf_thr=2, clean_depth=False):
143
+ if 'save_pointcloud_with_normals' not in globals():
144
+ sys.path.append(os.path.join(os.path.dirname(__file__), '../wild-gaussian-splatting/gaussian-splatting'))
145
+ sys.path.append(os.path.join(os.path.dirname(__file__), '../wild-gaussian-splatting/src'))
146
+ from colmap_dataset_utils import (
147
+ inv,
148
+ init_filestructure,
149
+ save_images_masks,
150
+ save_cameras,
151
+ save_imagestxt,
152
+ save_pointcloud,
153
+ save_pointcloud_with_normals
154
+ )
155
+
156
+ cam2world = scene.get_im_poses().detach().cpu().numpy()
157
+ world2cam = inv(cam2world) #
158
+ principal_points = scene.get_principal_points().detach().cpu().numpy()
159
+ focals = scene.get_focals().detach().cpu().numpy()[..., None]
160
+ imgs = np.array(scene.imgs)
161
+
162
+ pts3d, _, confs = scene.get_dense_pts3d(clean_depth=clean_depth)
163
+ pts3d = [i.detach().reshape(imgs[0].shape) for i in pts3d] #
164
+
165
+ masks = to_numpy([c > min_conf_thr for c in to_numpy(confs)])
166
+
167
+ # move
168
+ mask_images = True
169
+
170
+ save_path, images_path, masks_path, sparse_path = init_filestructure(save_dir)
171
+ save_images_masks(imgs, masks, images_path, masks_path, mask_images)
172
+ save_cameras(focals, principal_points, sparse_path, imgs_shape=imgs.shape)
173
+ save_imagestxt(world2cam, sparse_path)
174
+ save_pointcloud_with_normals(imgs, pts3d, masks, sparse_path)
175
+ return save_path
176
 
177
  @spaces.GPU(duration=10)
178
  def get_reconstructed_scene(image_size, current_scene_state,
 
223
  os.makedirs(base_colmapdata_dir, exist_ok=True)
224
  colmap_data_dir = get_next_dir(base_colmapdata_dir)
225
  #
226
+ save_colmap_scene(scene, colmap_data_dir, min_conf_thr, clean_depth)
 
 
 
227
 
228
  if current_scene_state is not None and \
229
  current_scene_state.outfile_name is not None:
 
266
  return win_col, winsize, win_cyclic, refid
267
 
268
 
 
 
 
 
 
 
269
  def mast3r_demo_tab():
270
 
271
  if not SILENT:
requirements.txt CHANGED
@@ -15,8 +15,8 @@ tensorboard
15
  pyglet<2
16
  roma
17
 
18
- https://huggingface.co/spaces/ostapagon/mast3r-3dgs/resolve/main/wheels/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl?download=true
19
  https://huggingface.co/spaces/ostapagon/mast3r-3dgs/resolve/main/wheels/simple_knn-0.0.0-cp310-cp310-linux_x86_64.whl?download=true
 
20
 
21
  camtools==0.1.4
22
  einops==0.7.0
 
15
  pyglet<2
16
  roma
17
 
 
18
  https://huggingface.co/spaces/ostapagon/mast3r-3dgs/resolve/main/wheels/simple_knn-0.0.0-cp310-cp310-linux_x86_64.whl?download=true
19
+ https://huggingface.co/spaces/ostapagon/mast3r-3dgs/resolve/main/wheels/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl?download=true
20
 
21
  camtools==0.1.4
22
  einops==0.7.0
wheels/simple_knn-0.0.0-cp310-cp310-linux_x86_64.whl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:59729fbacdab4fff910203ee283a8aca6452a389e11c648640d83e9ae42bb906
3
- size 2913535
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5d186b907917fba676b89dbe35e644fa617cf73781b94da0740648c09829611
3
+ size 3089436