Jie Hu commited on
Commit ·
1d77203
1
Parent(s): da9ce9e
init project
Browse files38 unmodified lines3940414243444546197 unmodified lines24424524624724824948 unmodified lines298299300301302303304305306126 unmodified lines43343443543643743843944044144244344444544644744844945045145245345445545645738 unmodified linessilent = Falsepe3r = Models('cuda' if torch.cuda.is_available() else 'cpu')def _convert_scene_output_to_glb(outdir, imgs, pts3d, mask, focals, cams2world, cam_size=0.05,cam_color=None, as_pointcloud=False,197 unmodified linesreturn interpolated_vector@torch.no_graddef get_mask_from_img_sam1(mobilesamv2, yolov8, sam1_image, yolov8_image, original_size, input_size, transform):device = 'cuda' if torch.cuda.is_available() else 'cpu'48 unmodified linesreturn ret_mask@torch.no_graddef get_cog_feats(images):device = 'cuda' if torch.cuda.is_available() else 'cpu'cog_seg_maps = []rev_cog_seg_maps = []inference_state = pe3r.sam2.init_state(images=images.sam2_images, video_height=images.sam2_video_size[0], video_width=images.sam2_video_size[1])126 unmodified linesmulti_view_clip_feats[i] = torch.zeros((1024))multi_view_clip_feats[mask_num] = torch.zeros((1024))return cog_seg_maps, rev_cog_seg_maps, multi_view_clip_feats@spaces.GPU(duration=180)def get_reconstructed_scene(outdir, filelist, schedule, niter, min_conf_thr,as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size,scenegraph_type, winsize, refid):"""from a list of images, run dust3r inference, global aligner.then run get_3D_model_from_scene"""if len(filelist) < 2:raise gradio.Error("Please input at least 2 images.")device = 'cuda' if torch.cuda.is_available() else 'cpu'images = Images(filelist=filelist, device=device)# try:cog_seg_maps, rev_cog_seg_maps, cog_feats = get_cog_feats(images)imgs = load_images(images, rev_cog_seg_maps, size=512, verbose=not silent)# except Exception as e:# rev_cog_seg_maps = []38 unmodified lines394041424344197 unmodified lines24224324424524624724848 unmodified lines297298299300301302303304305306307308309310311312313314315316317318319320126 unmodified lines44744844945045145245345438 unmodified linessilent = Falsedef _convert_scene_output_to_glb(outdir, imgs, pts3d, mask, focals, cams2world, cam_size=0.05,cam_color=None, as_pointcloud=False,197 unmodified linesreturn interpolated_vector@torch.no_grad@spaces.GPU(duration=180)def get_mask_from_img_sam1(mobilesamv2, yolov8, sam1_image, yolov8_image, original_size, input_size, transform):device = 'cuda' if torch.cuda.is_available() else 'cpu'48 unmodified linesreturn ret_mask@spaces.GPU(duration=180)def get_reconstructed_scene(outdir, filelist, schedule, niter, min_conf_thr,as_pointcloud, mask_sky, clean_depth, transparent_cams, cam_size,scenegraph_type, winsize, refid):"""from a list of images, run dust3r inference, global aligner.then run get_3D_model_from_scene"""if len(filelist) < 2:raise gradio.Error("Please input at least 2 images.")device = 'cuda' if torch.cuda.is_available() else 'cpu'pe3r = Models(device)images = Images(filelist=filelist, device=device)# try:cog_seg_maps = []rev_cog_seg_maps = []inference_state = pe3r.sam2.init_state(images=images.sam2_images, video_height=images.sam2_video_size[0], video_width=images.sam2_video_size[1])126 unmodified linesmulti_view_clip_feats[i] = torch.zeros((1024))multi_view_clip_feats[mask_num] = torch.zeros((1024))cog_feats = multi_view_clip_featsimgs = load_images(images, rev_cog_seg_maps, size=512, verbose=not silent)# except Exception as e:# rev_cog_seg_maps = []
app.py+19-22