def forward(self, data): if self._backbone_name == "kpconv": # KPConv needs added ones for its x features data = AddOnes()(data) data.x = data.ones data_out = self._model["backbone"](data) return F.log_softmax(self._model["classifier"](data_out.x).squeeze(), dim=-1)
def set_input(self, data, device): """Unpack input data from the dataloader and perform necessary pre-processing steps. Parameters: input: a dictionary that contains the data itself and its metadata information. """ self.semantic_labels = data.y.flatten().to(self.device) if self.is_dense_format: self.input = data self._n_batches = data.pos.shape[0] else: if self._kpconv_backbone: data = AddOnes()(data) if data.x is not None: data.x = torch.cat([data.x, data.ones.float()], dim=-1) else: data.x = data.ones.float() self.input = data self._n_batches = torch.max(data.batch) + 1
def _set_input(self, data): """Unpack input data from the dataloader and perform necessary pre-processing steps. Parameters: input: a dictionary that contains the data itself and its metadata information. """ # Forward through backbone model if self.is_dense_format: self.input = data self._num_batches = data.pos.shape[0] else: if self._kpconv_backbone: data = AddOnes()(data) if data.x is not None: data.x = torch.cat([data.x, data.ones.float()], dim=-1) else: data.x = data.ones.float() self.input = Data(pos=data.pos, x=data.x, batch=data.batch).to(self.device) self._num_batches = len(data.id_scan)
-6.481465826011e-03, 8.051860151134e-03, -9.999466081774e-01, -7.337429464231e-02 ], [ 9.999773098287e-01, -1.805528627661e-03, -6.496203536139e-03, -3.339968064433e-01 ], ]) pcd_s = np.fromfile(path_s, dtype=np.float32).reshape(-1, 4)[:, :3].dot( R_calib[:3, :3].T) pcd_t = np.fromfile(path_t, dtype=np.float32).reshape(-1, 4)[:, :3].dot( R_calib[:3, :3].T) transform = Compose([ GridSampling3D(mode="last", size=0.3, quantize_coords=True), AddOnes(), AddFeatByKey(add_to_x=True, feat_name="ones"), ]) data_s = transform( Batch(pos=torch.from_numpy(pcd_s).float(), batch=torch.zeros(pcd_s.shape[0]).long())) data_t = transform( Batch(pos=torch.from_numpy(pcd_t).float(), batch=torch.zeros(pcd_t.shape[0]).long())) model = PretainedRegistry.from_pretrained( "minkowski-registration-kitti").cuda() with torch.no_grad(): model.set_input(data_s, "cuda")