app.py
CHANGED
@@ -80,7 +80,7 @@ def get_3D_model_from_scene(outdir, silent, scene, min_conf_thr=3, as_pointcloud
|
|
80 |
return convert_scene_output_to_glb(outdir, rgbimg, pts3d, msk, focals, cams2world, as_pointcloud=as_pointcloud,
|
81 |
transparent_cams=transparent_cams, cam_size=cam_size, show_cam=show_cam, silent=silent, save_name=save_name,
|
82 |
cam_color=cam_color)
|
83 |
-
|
84 |
@spaces.GPU(duration=180)
|
85 |
def generate_monocular_depth_maps(img_list, depth_prior_name):
|
86 |
depth_list = []
|
@@ -120,9 +120,11 @@ def generate_monocular_depth_maps(img_list, depth_prior_name):
|
|
120 |
def local_get_reconstructed_scene(filelist, min_conf_thr, as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size, depth_prior_name, **kw):
|
121 |
depth_list, focallength_px_list = generate_monocular_depth_maps(filelist, depth_prior_name)
|
122 |
imgs = load_images(filelist, depth_list, focallength_px_list, size=image_size, verbose=not silent,traj_format='custom', depth_prior_name=depth_prior_name)
|
123 |
-
pairs = []
|
124 |
-
pairs.append((imgs[0], imgs[1]))
|
125 |
-
pairs.append((imgs[1], imgs[0]))
|
|
|
|
|
126 |
if depth_prior_name == "Depth Pro":
|
127 |
weights_path = "cyun9286/Align3R_DepthPro_ViTLarge_BaseDecoder_512_dpt"
|
128 |
else:
|
@@ -130,8 +132,15 @@ def local_get_reconstructed_scene(filelist, min_conf_thr, as_pointcloud, mask_sk
|
|
130 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
131 |
model = AsymmetricCroCo3DStereo.from_pretrained(weights_path).to(device)
|
132 |
output = inference(pairs, model, device, batch_size=batch_size, verbose=not silent)
|
133 |
-
mode = GlobalAlignerMode.
|
134 |
-
scene = global_aligner(output, device=device, mode=mode, verbose=not silent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
save_folder = './output'
|
136 |
os.makedirs(save_folder, exist_ok=True)
|
137 |
outfile = get_3D_model_from_scene(save_folder, silent, scene, min_conf_thr, as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size)
|
@@ -141,7 +150,7 @@ def local_get_reconstructed_scene(filelist, min_conf_thr, as_pointcloud, mask_sk
|
|
141 |
|
142 |
def run_example(snapshot, matching_conf_thr, min_conf_thr, cam_size, as_pointcloud, shared_intrinsics, filelist, **kw):
|
143 |
return local_get_reconstructed_scene(filelist, cam_size, **kw)
|
144 |
-
# filelist = ['/home/lipeng/ljh_code/Video_Depth_CVPR2025-main/Align3R/data/davis/DAVIS/JPEGImages/480p/bear/00000.jpg', '/home/lipeng/ljh_code/Video_Depth_CVPR2025-main/Align3R/data/davis/DAVIS/JPEGImages/480p/bear/00010.jpg']
|
145 |
# min_conf_thr = 1.1
|
146 |
# as_pointcloud = True
|
147 |
# mask_sky = False
|
|
|
80 |
return convert_scene_output_to_glb(outdir, rgbimg, pts3d, msk, focals, cams2world, as_pointcloud=as_pointcloud,
|
81 |
transparent_cams=transparent_cams, cam_size=cam_size, show_cam=show_cam, silent=silent, save_name=save_name,
|
82 |
cam_color=cam_color)
|
83 |
+
|
84 |
@spaces.GPU(duration=180)
|
85 |
def generate_monocular_depth_maps(img_list, depth_prior_name):
|
86 |
depth_list = []
|
|
|
120 |
def local_get_reconstructed_scene(filelist, min_conf_thr, as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size, depth_prior_name, **kw):
|
121 |
depth_list, focallength_px_list = generate_monocular_depth_maps(filelist, depth_prior_name)
|
122 |
imgs = load_images(filelist, depth_list, focallength_px_list, size=image_size, verbose=not silent,traj_format='custom', depth_prior_name=depth_prior_name)
|
123 |
+
# pairs = []
|
124 |
+
# pairs.append((imgs[0], imgs[1]))
|
125 |
+
# pairs.append((imgs[1], imgs[0]))
|
126 |
+
scenegraph_type = 'swinstride-5-noncyclic'
|
127 |
+
pairs = make_pairs(imgs, scene_graph=scenegraph_type, prefilter=None, symmetrize=True)
|
128 |
if depth_prior_name == "Depth Pro":
|
129 |
weights_path = "cyun9286/Align3R_DepthPro_ViTLarge_BaseDecoder_512_dpt"
|
130 |
else:
|
|
|
132 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
133 |
model = AsymmetricCroCo3DStereo.from_pretrained(weights_path).to(device)
|
134 |
output = inference(pairs, model, device, batch_size=batch_size, verbose=not silent)
|
135 |
+
mode = GlobalAlignerMode.PointCloudOptimizer
|
136 |
+
scene = global_aligner(output, device=device, mode=mode, verbose=not silent, shared_focal = True, temporal_smoothing_weight=0.01, translation_weight=1.0,
|
137 |
+
flow_loss_weight=0.01, flow_loss_start_epoch=0.1, flow_loss_thre=25, use_self_mask=True,
|
138 |
+
num_total_iter=300, empty_cache= len(filelist) > 72)
|
139 |
+
lr = 0.01
|
140 |
+
if mode == GlobalAlignerMode.PointCloudOptimizer:
|
141 |
+
loss = scene.compute_global_alignment(init='mst', niter=300, schedule='linear', lr=lr)
|
142 |
+
# mode = GlobalAlignerMode.PairViewer
|
143 |
+
# scene = global_aligner(output, device=device, mode=mode, verbose=not silent)
|
144 |
save_folder = './output'
|
145 |
os.makedirs(save_folder, exist_ok=True)
|
146 |
outfile = get_3D_model_from_scene(save_folder, silent, scene, min_conf_thr, as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size)
|
|
|
150 |
|
151 |
def run_example(snapshot, matching_conf_thr, min_conf_thr, cam_size, as_pointcloud, shared_intrinsics, filelist, **kw):
|
152 |
return local_get_reconstructed_scene(filelist, cam_size, **kw)
|
153 |
+
# filelist = ['/home/lipeng/ljh_code/Video_Depth_CVPR2025-main/Align3R/data/davis/DAVIS/JPEGImages/480p/bear/00000.jpg', '/home/lipeng/ljh_code/Video_Depth_CVPR2025-main/Align3R/data/davis/DAVIS/JPEGImages/480p/bear/00008.jpg','/home/lipeng/ljh_code/Video_Depth_CVPR2025-main/Align3R/data/davis/DAVIS/JPEGImages/480p/bear/00004.jpg', '/home/lipeng/ljh_code/Video_Depth_CVPR2025-main/Align3R/data/davis/DAVIS/JPEGImages/480p/bear/00010.jpg']
|
154 |
# min_conf_thr = 1.1
|
155 |
# as_pointcloud = True
|
156 |
# mask_sky = False
|
dust3r/cloud_opt_flow/__pycache__/pair_viewer.cpython-311.pyc
CHANGED
Binary files a/dust3r/cloud_opt_flow/__pycache__/pair_viewer.cpython-311.pyc and b/dust3r/cloud_opt_flow/__pycache__/pair_viewer.cpython-311.pyc differ
|
|
dust3r/utils/__pycache__/image_pose.cpython-311.pyc
CHANGED
Binary files a/dust3r/utils/__pycache__/image_pose.cpython-311.pyc and b/dust3r/utils/__pycache__/image_pose.cpython-311.pyc differ
|
|