MCPcopy Create free account
hub / github.com/IRMVLab/SemGauss-SLAM / initialize_first_timestep

Function initialize_first_timestep

sem_gauss.py:143–178  ·  view source on GitHub ↗
(dataset, num_frames, scene_radius_depth_ratio, mean_sq_dist_method, seg_net)

Source from the content-addressed store, hash-verified

141 return torch.optim.Adam(param_groups, lr=0.0, eps=1e-15)
142
143def initialize_first_timestep(dataset, num_frames, scene_radius_depth_ratio, mean_sq_dist_method, seg_net):
144 # Get RGB-D Data & semantic & Camera Parameters
145 color, depth, semantic, intrinsics, pose = dataset[0]
146
147
148 # get semantic feature
149 rgb_input = color.permute(2, 0, 1).unsqueeze(0).cuda()/255.0 # [1,3,H,W]
150 seg_net.set_mode_get_feature()
151 sem_feature = seg_net.cnn(rgb_input) # [1,16,H,W] #TODO: sem_feature和color都在gpu上(cuda:0)
152 sem_feature = sem_feature.squeeze(0).detach() # [16,H,W]
153
154 # Process RGB-D Data
155 depth = depth.permute(2, 0, 1) # (H, W, C) -> (C, H, W)
156 color = color.permute(2, 0, 1) / 255
157
158 # Process Camera Parameters
159 intrinsics = intrinsics[:3, :3]
160 w2c = torch.linalg.inv(pose)
161
162 # Setup Camera
163 cam = setup_camera(color.shape[2], color.shape[1], intrinsics.cpu().numpy(), w2c.detach().cpu().numpy())
164
165 # Get Initial Point Cloud (PyTorch CUDA Tensor)
166 mask = (depth > 0) # Mask out invalid depth values
167 mask = mask.reshape(-1)
168 init_pt_cld, mean3_sq_dist = get_pointcloud(color, depth, sem_feature, intrinsics, w2c,
169 mask=mask, compute_mean_sq_dist=True,
170 mean_sq_dist_method=mean_sq_dist_method)
171
172 # Initialize Parameters
173 params, variables = initialize_params(init_pt_cld, num_frames, mean3_sq_dist)
174
175 # Initialize an estimate of scene radius for Gaussian-Splatting Densification
176 variables['scene_radius'] = torch.max(depth)/scene_radius_depth_ratio
177
178 return params, variables, intrinsics, w2c, cam
179
180def get_loss(params, curr_data, variables, iter_time_idx, loss_weights, use_sil_for_loss,
181 sil_thres, use_l1,ignore_outlier_depth_loss, seg_net, tracking=False,

Callers 1

dense_semantic_slamFunction · 0.85

Calls 5

setup_cameraFunction · 0.90
initialize_paramsFunction · 0.85
set_mode_get_featureMethod · 0.80
maxMethod · 0.80
get_pointcloudFunction · 0.70

Tested by

no test coverage detected