def get_dataset(conv_type, task): num_points = 1024 features = 2 batch_size = 2 if task == "object_detection": include_box = True else: include_box = False if conv_type.lower() == "dense": num_points = 2048 batch_size = 1 if task == "registration": if conv_type.lower() == "dense": return PairMockDataset(features, num_points=num_points, batch_size=batch_size) if conv_type.lower() == "sparse": tr = Compose([ XYZFeature(True, True, True), GridSampling3D(size=0.01, quantize_coords=True, mode="last") ]) return PairMockDatasetGeometric(features, transform=tr, num_points=num_points, batch_size=batch_size) return PairMockDatasetGeometric(features, batch_size=batch_size) else: if conv_type.lower() == "dense": num_points = 2048 return MockDataset( features, num_points=num_points, include_box=include_box, panoptic=task == "panoptic", batch_size=batch_size, ) if conv_type.lower() == "sparse": return MockDatasetGeometric( features, include_box=include_box, panoptic=task == "panoptic", transform=Compose([ XYZFeature(True, True, True), GridSampling3D(size=0.01, quantize_coords=True, mode="last") ]), num_points=num_points, batch_size=batch_size, ) return MockDatasetGeometric( features, batch_size=batch_size, num_points=num_points, include_box=include_box, panoptic=task == "panoptic", )
def get_dataset(conv_type, task): features = 2 if task == "registration": if conv_type.lower() == "dense": return PairMockDataset(features, num_points=2048) if conv_type.lower() == "sparse": tr = Compose([ XYZFeature(True, True, True), GridSampling(size=0.01, quantize_coords=True, mode="last") ]) return PairMockDatasetGeometric(features, transform=tr, num_points=1024) return PairMockDatasetGeometric(features) else: if conv_type.lower() == "dense": return MockDataset(features, num_points=2048) if conv_type.lower() == "sparse": return MockDatasetGeometric(features, transform=GridSampling( size=0.01, quantize_coords=True, mode="last"), num_points=1024) return MockDatasetGeometric(features)
def test_siamese_minkowski(self): params = load_model_config("registration", "minkowski", "MinkUNet_Fragment") transform = Compose( [XYZFeature(True, True, True), GridSampling3D(size=0.01, quantize_coords=True, mode="last")] ) dataset = PairMockDatasetGeometric(5, transform=transform, num_points=1024, is_pair_ind=True) model = instantiate_model(params, dataset) d = dataset[0] model.set_input(d, device) model.forward() model.backward() ratio = test_hasgrad(model) if ratio < 1: print( "Model registration.minkowski.MinkUNet_Fragment has %i%% of parameters with 0 gradient" % (100 * ratio) )
def test_siamese_minkowski(self): params = load_model_config("registration", "minkowski", "MinkUNet_Fragment") transform = Compose([ XYZFeature(True, True, True), GridSampling(size=0.01, quantize_coords=True, mode="last") ]) dataset = PairMockDatasetGeometric(5, transform=transform, num_points=1024, is_pair_ind=True) model = instantiate_model(params, dataset) d = dataset[0] model.set_input(d, device) model.forward() model.backward()
def test_XYZFeature(self): pos = torch.from_numpy(np.asarray([[1, 2, 3], [4, 5, 6], [7, 8, 9]])) data = Data(pos=pos) t = XYZFeature() data_out = t(data.clone()) x = data_out.z self.assertEqual(np.array_equal(x, pos[:, -1]), True) pos += 1 self.assertEqual(np.array_equal(x, pos[:, -1]), False) self.assertIn("z", data_out.keys) self.assertIn("pos", data_out.keys) self.assertNotIn("x", data_out.keys) self.assertNotIn("y", data_out.keys)