(init_pt_cld, num_frames, mean3_sq_dist)
| 98 | |
| 99 | |
| 100 | def initialize_params(init_pt_cld, num_frames, mean3_sq_dist): |
| 101 | num_pts = init_pt_cld.shape[0] |
| 102 | means3D = init_pt_cld[:, :3] # [num_gaussians, 3] |
| 103 | unnorm_rots = np.tile([1, 0, 0, 0], (num_pts, 1)) # [num_gaussians, 3] |
| 104 | logit_opacities = torch.zeros((num_pts, 1), dtype=torch.float, device="cuda") |
| 105 | |
| 106 | params = { |
| 107 | 'means3D': means3D, |
| 108 | 'rgb_colors': init_pt_cld[:, 3:6], |
| 109 | 'sem_labels' : init_pt_cld[:, 6:], |
| 110 | 'unnorm_rotations': unnorm_rots, |
| 111 | 'logit_opacities': logit_opacities, |
| 112 | 'log_scales': torch.tile(torch.log(torch.sqrt(mean3_sq_dist))[..., None], (1, 1)), |
| 113 | } |
| 114 | |
| 115 | cam_rots = np.tile([1, 0, 0, 0], (1, 1)) |
| 116 | cam_rots = np.tile(cam_rots[:, :, None], (1, 1, num_frames)) |
| 117 | params['cam_unnorm_rots'] = cam_rots |
| 118 | params['cam_trans'] = np.zeros((1, 3, num_frames)) |
| 119 | |
| 120 | for k, v in params.items(): |
| 121 | # Check if value is already a torch tensor |
| 122 | if not isinstance(v, torch.Tensor): |
| 123 | params[k] = torch.nn.Parameter(torch.tensor(v).cuda().float().contiguous().requires_grad_(True)) |
| 124 | else: |
| 125 | params[k] = torch.nn.Parameter(v.cuda().float().contiguous().requires_grad_(True)) |
| 126 | |
| 127 | variables = {'max_2D_radius': torch.zeros(params['means3D'].shape[0]).cuda().float(), |
| 128 | 'means2D_gradient_accum': torch.zeros(params['means3D'].shape[0]).cuda().float(), |
| 129 | 'denom': torch.zeros(params['means3D'].shape[0]).cuda().float(), |
| 130 | 'timestep': torch.zeros(params['means3D'].shape[0]).cuda().float()} |
| 131 | |
| 132 | return params, variables |
| 133 | |
| 134 | |
| 135 | def initialize_optimizer(params, lrs_dict, tracking): |
no outgoing calls
no test coverage detected