| 339 | return loss, variables, weighted_losses |
| 340 | |
| 341 | def initialize_new_params(new_pt_cld, mean3_sq_dist): |
| 342 | num_pts = new_pt_cld.shape[0] |
| 343 | means3D = new_pt_cld[:, :3] # [num_gaussians, 3] |
| 344 | unnorm_rots = np.tile([1, 0, 0, 0], (num_pts, 1)) # [num_gaussians, 3] |
| 345 | logit_opacities = torch.zeros((num_pts, 1), dtype=torch.float, device="cuda") |
| 346 | params = { |
| 347 | 'means3D': means3D, |
| 348 | 'rgb_colors': new_pt_cld[:, 3:6], |
| 349 | 'sem_labels': new_pt_cld[:, 6:], |
| 350 | 'unnorm_rotations': unnorm_rots, |
| 351 | 'logit_opacities': logit_opacities, |
| 352 | 'log_scales': torch.tile(torch.log(torch.sqrt(mean3_sq_dist))[..., None], (1, 1)), |
| 353 | } |
| 354 | for k, v in params.items(): |
| 355 | # Check if value is already a torch tensor |
| 356 | if not isinstance(v, torch.Tensor): |
| 357 | params[k] = torch.nn.Parameter(torch.tensor(v).cuda().float().contiguous().requires_grad_(True)) |
| 358 | else: |
| 359 | params[k] = torch.nn.Parameter(v.cuda().float().contiguous().requires_grad_(True)) |
| 360 | |
| 361 | return params |
| 362 | |
| 363 | def add_new_gaussians(params, variables, curr_data, sil_thres, time_idx, mean_sq_dist_method, sem_feature): |
| 364 | # Silhouette Rendering |