ostapagon commited on
Commit
f2a83d8
·
1 Parent(s): 6d84364

Try inner functions

Browse files
Files changed (1) hide show
  1. demo/mast3r_demo.py +14 -14
demo/mast3r_demo.py CHANGED
@@ -174,6 +174,7 @@ def get_3D_model_from_scene(silent, scene_state, min_conf_thr=2, as_pointcloud=F
174
  # save_pointcloud_with_normals(imgs, pts3d, masks, sparse_path)
175
  # return save_path
176
 
 
177
  def get_reconstructed_scene(outdir, model, device, silent, image_size, current_scene_state,
178
  filelist, optim_level, lr1, niter1, lr2, niter2, min_conf_thr, matching_conf_thr,
179
  as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size, scenegraph_type, winsize,
@@ -265,19 +266,18 @@ def set_scenegraph_options(inputfiles, win_cyclic, refid, scenegraph_type):
265
  return win_col, winsize, win_cyclic, refid
266
 
267
 
268
- @spaces.GPU(duration=10)
269
- def get_reconstructed_scene_wrapper_func(cache_path, model, device, silent, *args, **kwargs):
270
- return get_reconstructed_scene(cache_path, model, device, silent, *args, **kwargs)
271
-
272
- def get_3D_model_from_scene_wrapper_func(silent, *args, **kwargs):
273
- return get_3D_model_from_scene(silent, *args, **kwargs)
274
-
275
  def mast3r_demo_tab(cache_path, weights_path, device, silent=False):
276
  model = AsymmetricMASt3R.from_pretrained(weights_path).to(device)
277
 
278
  if not silent:
279
  print('Outputing stuff in', cache_path)
280
 
 
 
 
 
 
 
281
  def get_context():
282
  css = """.gradio-container {margin: 0 !important; min-width: 100%};"""
283
  title = "MASt3R Demo"
@@ -351,31 +351,31 @@ def mast3r_demo_tab(cache_path, weights_path, device, silent=False):
351
  outputs=[scene, outmodel]
352
  )
353
  min_conf_thr.release(
354
- fn=get_3D_model_from_scene_wrapper_func,
355
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size, TSDF_thresh],
356
  outputs=outmodel
357
  )
358
- cam_size.change(fn=lambda *args, **kwargs: get_3D_model_from_scene_wrapper_func(silent, *args, **kwargs),
359
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
360
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
361
  outputs=outmodel)
362
- TSDF_thresh.change(fn=lambda *args, **kwargs: get_3D_model_from_scene_wrapper_func(silent, *args, **kwargs),
363
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
364
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
365
  outputs=outmodel)
366
- as_pointcloud.change(fn=lambda *args, **kwargs: get_3D_model_from_scene_wrapper_func(silent, *args, **kwargs),
367
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
368
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
369
  outputs=outmodel)
370
- mask_sky.change(fn=lambda *args, **kwargs: get_3D_model_from_scene_wrapper_func(silent, *args, **kwargs),
371
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
372
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
373
  outputs=outmodel)
374
- clean_depth.change(fn=lambda *args, **kwargs: get_3D_model_from_scene_wrapper_func(silent, *args, **kwargs),
375
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
376
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
377
  outputs=outmodel)
378
- transparent_cams.change(fn=lambda *args, **kwargs: get_3D_model_from_scene_wrapper_func(silent, *args, **kwargs),
379
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
380
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
381
  outputs=outmodel)
 
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(outdir, model, device, silent, image_size, current_scene_state,
179
  filelist, optim_level, lr1, niter1, lr2, niter2, min_conf_thr, matching_conf_thr,
180
  as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size, scenegraph_type, winsize,
 
266
  return win_col, winsize, win_cyclic, refid
267
 
268
 
 
 
 
 
 
 
 
269
  def mast3r_demo_tab(cache_path, weights_path, device, silent=False):
270
  model = AsymmetricMASt3R.from_pretrained(weights_path).to(device)
271
 
272
  if not silent:
273
  print('Outputing stuff in', cache_path)
274
 
275
+ def get_reconstructed_scene_wrapper_func(*args, **kwargs):
276
+ return get_reconstructed_scene(cache_path, model, device, silent, *args, **kwargs)
277
+
278
+ def update_3D_model_from_scene(silent, *args, **kwargs):
279
+ return get_3D_model_from_scene(silent, *args, **kwargs)
280
+
281
  def get_context():
282
  css = """.gradio-container {margin: 0 !important; min-width: 100%};"""
283
  title = "MASt3R Demo"
 
351
  outputs=[scene, outmodel]
352
  )
353
  min_conf_thr.release(
354
+ fn=update_3D_model_from_scene,
355
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size, TSDF_thresh],
356
  outputs=outmodel
357
  )
358
+ cam_size.change(fn=update_3D_model_from_scene,
359
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
360
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
361
  outputs=outmodel)
362
+ TSDF_thresh.change(fn=update_3D_model_from_scene,
363
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
364
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
365
  outputs=outmodel)
366
+ as_pointcloud.change(fn=update_3D_model_from_scene,
367
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
368
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
369
  outputs=outmodel)
370
+ mask_sky.change(fn=update_3D_model_from_scene,
371
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
372
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
373
  outputs=outmodel)
374
+ clean_depth.change(fn=update_3D_model_from_scene,
375
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
376
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
377
  outputs=outmodel)
378
+ transparent_cams.change(fn=update_3D_model_from_scene,
379
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
380
  clean_depth, transparent_cams, cam_size, TSDF_thresh],
381
  outputs=outmodel)