Jie Hu
commited on
Commit
·
1d77203
1
Parent(s):
da9ce9e
init project
Browse files
app.py
CHANGED
@@ -39,8 +39,6 @@ import torchvision.transforms as tvf
|
|
39 |
|
40 |
|
41 |
silent = False
|
42 |
-
pe3r = Models('cuda' if torch.cuda.is_available() else 'cpu')
|
43 |
-
|
44 |
|
45 |
def _convert_scene_output_to_glb(outdir, imgs, pts3d, mask, focals, cams2world, cam_size=0.05,
|
46 |
cam_color=None, as_pointcloud=False,
|
@@ -244,6 +242,7 @@ def slerp_multiple(vectors, t_values):
|
|
244 |
return interpolated_vector
|
245 |
|
246 |
@torch.no_grad
|
|
|
247 |
def get_mask_from_img_sam1(mobilesamv2, yolov8, sam1_image, yolov8_image, original_size, input_size, transform):
|
248 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
249 |
|
@@ -298,9 +297,24 @@ def get_mask_from_img_sam1(mobilesamv2, yolov8, sam1_image, yolov8_image, origin
|
|
298 |
|
299 |
return ret_mask
|
300 |
|
301 |
-
@
|
302 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
cog_seg_maps = []
|
305 |
rev_cog_seg_maps = []
|
306 |
inference_state = pe3r.sam2.init_state(images=images.sam2_images, video_height=images.sam2_video_size[0], video_width=images.sam2_video_size[1])
|
@@ -433,25 +447,8 @@ def get_cog_feats(images):
|
|
433 |
multi_view_clip_feats[i] = torch.zeros((1024))
|
434 |
multi_view_clip_feats[mask_num] = torch.zeros((1024))
|
435 |
|
436 |
-
|
437 |
|
438 |
-
@spaces.GPU(duration=180)
|
439 |
-
def get_reconstructed_scene(outdir, filelist, schedule, niter, min_conf_thr,
|
440 |
-
as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size,
|
441 |
-
scenegraph_type, winsize, refid):
|
442 |
-
"""
|
443 |
-
from a list of images, run dust3r inference, global aligner.
|
444 |
-
then run get_3D_model_from_scene
|
445 |
-
"""
|
446 |
-
if len(filelist) < 2:
|
447 |
-
raise gradio.Error("Please input at least 2 images.")
|
448 |
-
|
449 |
-
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
450 |
-
|
451 |
-
images = Images(filelist=filelist, device=device)
|
452 |
-
|
453 |
-
# try:
|
454 |
-
cog_seg_maps, rev_cog_seg_maps, cog_feats = get_cog_feats(images)
|
455 |
imgs = load_images(images, rev_cog_seg_maps, size=512, verbose=not silent)
|
456 |
# except Exception as e:
|
457 |
# rev_cog_seg_maps = []
|
|
|
39 |
|
40 |
|
41 |
silent = False
|
|
|
|
|
42 |
|
43 |
def _convert_scene_output_to_glb(outdir, imgs, pts3d, mask, focals, cams2world, cam_size=0.05,
|
44 |
cam_color=None, as_pointcloud=False,
|
|
|
242 |
return interpolated_vector
|
243 |
|
244 |
@torch.no_grad
|
245 |
+
@spaces.GPU(duration=180)
|
246 |
def get_mask_from_img_sam1(mobilesamv2, yolov8, sam1_image, yolov8_image, original_size, input_size, transform):
|
247 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
248 |
|
|
|
297 |
|
298 |
return ret_mask
|
299 |
|
300 |
+
@spaces.GPU(duration=180)
|
301 |
+
def get_reconstructed_scene(outdir, filelist, schedule, niter, min_conf_thr,
|
302 |
+
as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size,
|
303 |
+
scenegraph_type, winsize, refid):
|
304 |
+
"""
|
305 |
+
from a list of images, run dust3r inference, global aligner.
|
306 |
+
then run get_3D_model_from_scene
|
307 |
+
"""
|
308 |
+
if len(filelist) < 2:
|
309 |
+
raise gradio.Error("Please input at least 2 images.")
|
310 |
+
|
311 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
312 |
+
|
313 |
+
pe3r = Models(device)
|
314 |
+
|
315 |
+
images = Images(filelist=filelist, device=device)
|
316 |
+
|
317 |
+
# try:
|
318 |
cog_seg_maps = []
|
319 |
rev_cog_seg_maps = []
|
320 |
inference_state = pe3r.sam2.init_state(images=images.sam2_images, video_height=images.sam2_video_size[0], video_width=images.sam2_video_size[1])
|
|
|
447 |
multi_view_clip_feats[i] = torch.zeros((1024))
|
448 |
multi_view_clip_feats[mask_num] = torch.zeros((1024))
|
449 |
|
450 |
+
cog_feats = multi_view_clip_feats
|
451 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
imgs = load_images(images, rev_cog_seg_maps, size=512, verbose=not silent)
|
453 |
# except Exception as e:
|
454 |
# rev_cog_seg_maps = []
|