kxhit commited on
Commit
c7d42db
·
1 Parent(s): 580e407
Files changed (2) hide show
  1. app.py +6 -18
  2. dust3r/cloud_opt/commons.py +37 -37
app.py CHANGED
@@ -112,7 +112,7 @@ pipeline = pipeline.to(device)
112
  # pipeline.enable_xformers_memory_efficient_attention()
113
  # enable vae slicing
114
  pipeline.enable_vae_slicing()
115
- pipeline.enable_xformers_memory_efficient_attention()
116
 
117
 
118
 
@@ -183,7 +183,7 @@ def run_eschernet(eschernet_input_dict, sample_steps, sample_seed, nvs_num, nvs_
183
 
184
  # run inference
185
  # pipeline.to(device)
186
- # pipeline.enable_xformers_memory_efficient_attention()
187
  if CaPE_TYPE == "6DoF":
188
  with torch.autocast("cuda"):
189
  image = pipeline(input_imgs=input_image, prompt_imgs=input_image,
@@ -237,8 +237,6 @@ from dust3r.utils.image import load_images, rgb
237
  from dust3r.utils.device import to_numpy
238
  from dust3r.viz import add_scene_cam, CAM_COLORS, OPENGL, pts3d_to_trimesh, cat_meshes
239
  from dust3r.cloud_opt import global_aligner, GlobalAlignerMode
240
-
241
- import functools
242
  import math
243
 
244
  @spaces.GPU(duration=120)
@@ -699,9 +697,6 @@ with gr.Blocks() as demo:
699
  # scenegraph_type.change(set_scenegraph_options,
700
  # inputs=[input_image, winsize, refid, scenegraph_type],
701
  # outputs=[winsize, refid])
702
- input_image.change(set_scenegraph_options,
703
- inputs=[input_image, winsize, refid, scenegraph_type],
704
- outputs=[winsize, refid])
705
  # min_conf_thr.release(fn=model_from_scene_fun,
706
  # inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
707
  # clean_depth, transparent_cams, cam_size, same_focals],
@@ -732,6 +727,10 @@ with gr.Blocks() as demo:
732
  # scenegraph_type, winsize, refid, same_focals],
733
  # outputs=[scene, outmodel, processed_image, eschernet_input])
734
 
 
 
 
 
735
  run_dust3r.click(fn=get_reconstructed_scene,
736
  inputs=[input_image, schedule, niter, min_conf_thr, as_pointcloud,
737
  mask_sky, clean_depth, transparent_cams, cam_size,
@@ -740,21 +739,10 @@ with gr.Blocks() as demo:
740
 
741
 
742
  # events
743
- # preview images on input change
744
  input_image.change(fn=preview_input,
745
  inputs=[input_image],
746
  outputs=[processed_image])
747
 
748
- # submit.click(fn=generate_mvs,
749
- # inputs=[eschernet_input, sample_steps, sample_seed,
750
- # nvs_num, nvs_mode],
751
- # outputs=[mv_images, output_video],
752
- # )#.success(
753
- # # fn=make3d,
754
- # # inputs=[mv_images],
755
- # # outputs=[output_video, output_model_obj, output_model_glb]
756
- # # )
757
-
758
  submit.click(fn=run_eschernet,
759
  inputs=[eschernet_input, sample_steps, sample_seed,
760
  nvs_num, nvs_mode],
 
112
  # pipeline.enable_xformers_memory_efficient_attention()
113
  # enable vae slicing
114
  pipeline.enable_vae_slicing()
115
+ # pipeline.enable_xformers_memory_efficient_attention()
116
 
117
 
118
 
 
183
 
184
  # run inference
185
  # pipeline.to(device)
186
+ pipeline.enable_xformers_memory_efficient_attention()
187
  if CaPE_TYPE == "6DoF":
188
  with torch.autocast("cuda"):
189
  image = pipeline(input_imgs=input_image, prompt_imgs=input_image,
 
237
  from dust3r.utils.device import to_numpy
238
  from dust3r.viz import add_scene_cam, CAM_COLORS, OPENGL, pts3d_to_trimesh, cat_meshes
239
  from dust3r.cloud_opt import global_aligner, GlobalAlignerMode
 
 
240
  import math
241
 
242
  @spaces.GPU(duration=120)
 
697
  # scenegraph_type.change(set_scenegraph_options,
698
  # inputs=[input_image, winsize, refid, scenegraph_type],
699
  # outputs=[winsize, refid])
 
 
 
700
  # min_conf_thr.release(fn=model_from_scene_fun,
701
  # inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
702
  # clean_depth, transparent_cams, cam_size, same_focals],
 
727
  # scenegraph_type, winsize, refid, same_focals],
728
  # outputs=[scene, outmodel, processed_image, eschernet_input])
729
 
730
+ # events
731
+ input_image.change(set_scenegraph_options,
732
+ inputs=[input_image, winsize, refid, scenegraph_type],
733
+ outputs=[winsize, refid])
734
  run_dust3r.click(fn=get_reconstructed_scene,
735
  inputs=[input_image, schedule, niter, min_conf_thr, as_pointcloud,
736
  mask_sky, clean_depth, transparent_cams, cam_size,
 
739
 
740
 
741
  # events
 
742
  input_image.change(fn=preview_input,
743
  inputs=[input_image],
744
  outputs=[processed_image])
745
 
 
 
 
 
 
 
 
 
 
 
746
  submit.click(fn=run_eschernet,
747
  inputs=[eschernet_input, sample_steps, sample_seed,
748
  nvs_num, nvs_mode],
dust3r/cloud_opt/commons.py CHANGED
@@ -47,45 +47,45 @@ def get_imshapes(edges, pred_i, pred_j):
47
  return imshapes
48
 
49
 
50
- # def get_conf_trf(mode):
51
- # if mode == 'log':
52
- # def conf_trf(x): return x.log()
53
- # elif mode == 'sqrt':
54
- # def conf_trf(x): return x.sqrt()
55
- # elif mode == 'm1':
56
- # def conf_trf(x): return x-1
57
- # elif mode in ('id', 'none'):
58
- # def conf_trf(x): return x
59
- # else:
60
- # raise ValueError(f'bad mode for {mode=}')
61
- # return conf_trf
62
-
63
-
64
- def conf_trf_log(x):
65
- return x.log()
66
-
67
- def conf_trf_sqrt(x):
68
- return x.sqrt()
69
-
70
- def conf_trf_m1(x):
71
- return x - 1
72
-
73
- def conf_trf_id(x):
74
- return x
75
-
76
- # Mapping of modes to their corresponding functions
77
- conf_trf_map = {
78
- 'log': conf_trf_log,
79
- 'sqrt': conf_trf_sqrt,
80
- 'm1': conf_trf_m1,
81
- 'id': conf_trf_id,
82
- 'none': conf_trf_id
83
- }
84
-
85
  def get_conf_trf(mode):
86
- if mode not in conf_trf_map:
 
 
 
 
 
 
 
 
87
  raise ValueError(f'bad mode for {mode=}')
88
- return conf_trf_map[mode]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
 
91
 
 
47
  return imshapes
48
 
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  def get_conf_trf(mode):
51
+ if mode == 'log':
52
+ def conf_trf(x): return x.log()
53
+ elif mode == 'sqrt':
54
+ def conf_trf(x): return x.sqrt()
55
+ elif mode == 'm1':
56
+ def conf_trf(x): return x-1
57
+ elif mode in ('id', 'none'):
58
+ def conf_trf(x): return x
59
+ else:
60
  raise ValueError(f'bad mode for {mode=}')
61
+ return conf_trf
62
+
63
+
64
+ # def conf_trf_log(x):
65
+ # return x.log()
66
+ #
67
+ # def conf_trf_sqrt(x):
68
+ # return x.sqrt()
69
+ #
70
+ # def conf_trf_m1(x):
71
+ # return x - 1
72
+ #
73
+ # def conf_trf_id(x):
74
+ # return x
75
+ #
76
+ # # Mapping of modes to their corresponding functions
77
+ # conf_trf_map = {
78
+ # 'log': conf_trf_log,
79
+ # 'sqrt': conf_trf_sqrt,
80
+ # 'm1': conf_trf_m1,
81
+ # 'id': conf_trf_id,
82
+ # 'none': conf_trf_id
83
+ # }
84
+ #
85
+ # def get_conf_trf(mode):
86
+ # if mode not in conf_trf_map:
87
+ # raise ValueError(f'bad mode for {mode=}')
88
+ # return conf_trf_map[mode]
89
 
90
 
91