MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / __init__

Method __init__

examples/datasets/INVR_N3D.py:31–111  ·  view source on GitHub ↗
(
        self,
        model_path: str,
        source_path: str,
        loader: str ="colmap",
        images_phrase: str ="images",
        shuffle: bool = True,
        eval: bool = False,
        multiview: bool = False,
        duration: int = 5, # only for testing
        resolution_scales: list = [1.0],
        downscale_factor: int = 2,
        data_device: str = "cpu",
        test_view_id: List[int] = [0]
    )

Source from the content-addressed store, hash-verified

29 """COLMAP parser."""
30
31 def __init__(
32 self,
33 model_path: str,
34 source_path: str,
35 loader: str ="colmap",
36 images_phrase: str ="images",
37 shuffle: bool = True,
38 eval: bool = False,
39 multiview: bool = False,
40 duration: int = 5, # only for testing
41 resolution_scales: list = [1.0],
42 downscale_factor: int = 2,
43 data_device: str = "cpu",
44 test_view_id: List[int] = [0]
45 ):
46 self.model_path = model_path
47 self.source_path = source_path
48 self.images_phrase = images_phrase
49 self.eval = eval
50 self.duration = duration
51 self.resolution_scales = resolution_scales
52 self.test_view_id = test_view_id
53
54 self.train_cameras = {}
55 self.test_cameras = {}
56 raydict = {}
57
58 # Get scene info
59 ## Get cam parameters & merged point cloud for splats initialization
60 if loader == "colmap":
61 scene_info = sceneLoadTypeCallbacks["Colmap"](self.source_path, self.images_phrase, self.eval, multiview, duration=self.duration, test_view_id=self.test_view_id, downscale_factor=downscale_factor) # SceneInfo() - NamedTuple
62 # elif loader == "invr":
63 # scene_info = sceneLoadTypeCallbacks["INVR"](self.source_path, self.images_phrase, self.eval, multiview, duration=self.duration) # SceneInfo() - NamedTuple
64 else:
65 assert False, "Could not recognize scene type!"
66
67 with open(scene_info.ply_path, 'rb') as src_file, open(os.path.join(self.model_path, "init_pcd.ply") , 'wb') as dest_file:
68 dest_file.write(src_file.read())
69
70 self.cameras_extent = scene_info.nerf_normalization["radius"]
71 # need modification
72 class ModelParams():
73 def __init__(self):
74 self.downscale_factor = downscale_factor
75 self.data_device = data_device
76 args = ModelParams()
77 self.args = args
78
79 for resolution_scale in resolution_scales:
80 print("Loading Training Cameras")
81 self.train_cameras[resolution_scale] = cameraList_from_camInfosv2(scene_info.train_cameras, resolution_scale, args) # Dist[float, List[Camera()]]
82 print("Loading Test Cameras")
83 self.test_cameras[resolution_scale] = cameraList_from_camInfosv2(scene_info.test_cameras, resolution_scale, args) # Dist[float, List[Camera()]]
84
85 for cam in self.train_cameras[resolution_scale]:
86 if cam.image_name not in raydict and cam.rayo is not None:
87 # rays_o, rays_d = 1, cameradirect
88 raydict[cam.image_name] = torch.cat([cam.rayo, cam.rayd], dim=1) # 1 x 6 x H x W

Callers

nothing calls this directly

Calls 3

ModelParamsClass · 0.85
writeMethod · 0.80

Tested by

no test coverage detected