yocabon commited on
Commit
050f8f9
·
1 Parent(s): edff93e

minor change

Browse files
Files changed (1) hide show
  1. mast3r/demo.py +7 -9
mast3r/demo.py CHANGED
@@ -36,9 +36,6 @@ class SparseGAState():
36
  self.outfile_name = outfile_name
37
  self.should_delete = should_delete
38
 
39
- def __getattr__(self, name):
40
- return getattr(self.sparse_ga, name)
41
-
42
  def __del__(self):
43
  if self.cache_dir is not None and os.path.isdir(self.cache_dir):
44
  shutil.rmtree(self.cache_dir)
@@ -109,18 +106,19 @@ def _convert_scene_output_to_glb(outfile, imgs, pts3d, mask, focals, cams2world,
109
  return outfile
110
 
111
 
112
- def get_3D_model_from_scene(silent, scene, min_conf_thr=2, as_pointcloud=False, mask_sky=False,
113
  clean_depth=False, transparent_cams=False, cam_size=0.05, TSDF_thresh=0):
114
  """
115
  extract 3D_model (glb file) from a reconstructed scene
116
  """
117
- if scene is None:
118
  return None
119
- outfile = scene.outfile_name
120
  if outfile is None:
121
  return None
122
 
123
  # get optimized values from scene
 
124
  rgbimg = scene.imgs
125
  focals = scene.get_focals().cpu()
126
  cams2world = scene.get_im_poses().cpu()
@@ -177,10 +175,10 @@ def get_reconstructed_scene(outdir, gradio_delete_cache, model, device, silent,
177
  else:
178
  outfile_name = tempfile.mktemp(suffix='_scene.glb', dir=outdir)
179
 
180
- scene = SparseGAState(scene, gradio_delete_cache, cache_dir, outfile_name)
181
- outfile = get_3D_model_from_scene(silent, scene, min_conf_thr, as_pointcloud, mask_sky,
182
  clean_depth, transparent_cams, cam_size, TSDF_thresh)
183
- return scene, outfile
184
 
185
 
186
  def set_scenegraph_options(inputfiles, win_cyclic, refid, scenegraph_type):
 
36
  self.outfile_name = outfile_name
37
  self.should_delete = should_delete
38
 
 
 
 
39
  def __del__(self):
40
  if self.cache_dir is not None and os.path.isdir(self.cache_dir):
41
  shutil.rmtree(self.cache_dir)
 
106
  return outfile
107
 
108
 
109
+ def get_3D_model_from_scene(silent, scene_state, min_conf_thr=2, as_pointcloud=False, mask_sky=False,
110
  clean_depth=False, transparent_cams=False, cam_size=0.05, TSDF_thresh=0):
111
  """
112
  extract 3D_model (glb file) from a reconstructed scene
113
  """
114
+ if scene_state is None:
115
  return None
116
+ outfile = scene_state.outfile_name
117
  if outfile is None:
118
  return None
119
 
120
  # get optimized values from scene
121
+ scene = scene_state.sparse_ga
122
  rgbimg = scene.imgs
123
  focals = scene.get_focals().cpu()
124
  cams2world = scene.get_im_poses().cpu()
 
175
  else:
176
  outfile_name = tempfile.mktemp(suffix='_scene.glb', dir=outdir)
177
 
178
+ scene_state = SparseGAState(scene, gradio_delete_cache, cache_dir, outfile_name)
179
+ outfile = get_3D_model_from_scene(silent, scene_state, min_conf_thr, as_pointcloud, mask_sky,
180
  clean_depth, transparent_cams, cam_size, TSDF_thresh)
181
+ return scene_state, outfile
182
 
183
 
184
  def set_scenegraph_options(inputfiles, win_cyclic, refid, scenegraph_type):