Skip to content

Commit

Permalink
Add illustration.png, pcam, requirements.txt, setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyM1997 committed Oct 2, 2021
1 parent fe704d7 commit 1ef50d1
Show file tree
Hide file tree
Showing 51 changed files with 15,170 additions and 0 deletions.
Binary file added illustration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions pcam/configs/3dmatch/soft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATASET: '3dmatch'
NUM_POINTS: 4096
SPARSE_ATTENTION: False
5 changes: 5 additions & 0 deletions pcam/configs/3dmatch/soft_filter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DATASET: '3dmatch'
NUM_POINTS: 4096
SPARSE_ATTENTION: False
# This threshold was optimised on the validation of 3dmatch
THRESHOLD: .6
6 changes: 6 additions & 0 deletions pcam/configs/3dmatch/soft_refinement.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DATASET: '3dmatch'
NUM_POINTS: 4096
SPARSE_ATTENTION: False
# This threshold was optimised on the validation of 3dmatch
THRESHOLD: .6
DGR_OPTIM: True
10 changes: 10 additions & 0 deletions pcam/configs/3dmatch/soft_safeguard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DATASET: '3dmatch'
NUM_POINTS: 4096
SPARSE_ATTENTION: False
# This threshold was optimised on the validation of 3dmatch
THRESHOLD: .6
DGR_OPTIM: True
# Safeguard registration (as in DGR) when the confidence scores are below a threshold (WSUM_THRESHOLD)
# This threshold was optimised to apply safeguard on the same number of scans as in DGR
SAFEGUARD: True
WSUM_THRESHOLD: 930
3 changes: 3 additions & 0 deletions pcam/configs/3dmatch/sparse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATASET: '3dmatch'
NUM_POINTS: 4096
SPARSE_ATTENTION: True
5 changes: 5 additions & 0 deletions pcam/configs/3dmatch/sparse_filter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DATASET: '3dmatch'
NUM_POINTS: 4096
SPARSE_ATTENTION: True
# This threshold was optimised on the validation of 3dmatch
THRESHOLD: .5
6 changes: 6 additions & 0 deletions pcam/configs/3dmatch/sparse_refinement.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DATASET: '3dmatch'
NUM_POINTS: 4096
SPARSE_ATTENTION: True
# This threshold was optimised on the validation of 3dmatch
THRESHOLD: .5
DGR_OPTIM: True
10 changes: 10 additions & 0 deletions pcam/configs/3dmatch/sparse_safeguard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DATASET: '3dmatch'
NUM_POINTS: 4096
SPARSE_ATTENTION: True
# This threshold was optimised on the validation of 3dmatch
THRESHOLD: .5
DGR_OPTIM: True
# Safeguard registration (as in DGR) when the confidence scores are below a threshold (WSUM_THRESHOLD)
# This threshold was optimised to apply safeguard on the same number of scans as in DGR
SAFEGUARD: True
WSUM_THRESHOLD: 930
3 changes: 3 additions & 0 deletions pcam/configs/kitti/soft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATASET: 'kitti'
NUM_POINTS: 2048
SPARSE_ATTENTION: False
4 changes: 4 additions & 0 deletions pcam/configs/kitti/soft_icp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DATASET: 'kitti'
NUM_POINTS: 2048
SPARSE_ATTENTION: False
ICP: .6
3 changes: 3 additions & 0 deletions pcam/configs/kitti/sparse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATASET: 'kitti'
NUM_POINTS: 2048
SPARSE_ATTENTION: True
4 changes: 4 additions & 0 deletions pcam/configs/kitti/sparse_icp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DATASET: 'kitti'
NUM_POINTS: 2048
SPARSE_ATTENTION: True
ICP: .6
3 changes: 3 additions & 0 deletions pcam/configs/modelnet/soft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATASET: 'modelnet'
NUM_POINTS: 2048
SPARSE_ATTENTION: False
3 changes: 3 additions & 0 deletions pcam/configs/modelnet/soft_noise.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATASET: 'modelnet_noise'
NUM_POINTS: 2048
SPARSE_ATTENTION: False
3 changes: 3 additions & 0 deletions pcam/configs/modelnet/soft_unseen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATASET: 'modelnet_unseen'
NUM_POINTS: 2048
SPARSE_ATTENTION: False
3 changes: 3 additions & 0 deletions pcam/configs/modelnet/sparse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATASET: 'modelnet'
NUM_POINTS: 2048
SPARSE_ATTENTION: True
3 changes: 3 additions & 0 deletions pcam/configs/modelnet/sparse_noise.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATASET: 'modelnet_noise'
NUM_POINTS: 2048
SPARSE_ATTENTION: True
3 changes: 3 additions & 0 deletions pcam/configs/modelnet/sparse_unseen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATASET: 'modelnet_unseen'
NUM_POINTS: 2048
SPARSE_ATTENTION: True
13 changes: 13 additions & 0 deletions pcam/data/3dmatch/3dmatch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Dataset: 3DMatch

## Folder structure

Place the 3DMatch dataset in this folder (`/path/to/pcam/data/3dmatch/`), which should contain the following subfolders:
```
./threedmatch/ # Contains the training and validation set
./threedmatch/*.npz
./threedmatch/*.txt
./threedmatch_test/ # Contains the test set
./threedmatch_test/*.npz
./threedmatch_test/*.txt
```
14 changes: 14 additions & 0 deletions pcam/data/kitti/kitti.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Dataset: KITTI

## Folder structure

Place the KITTI dataset in this folder (`/path/to/pcam/data/kitti/`), which should contain the following subfolders:
```
./dataset/
./dataset/poses/
./dataset/poses/*.txt
./dataset/sequences/
./dataset/sequences/00/
./dataset/sequences/01/
etc.
```
12 changes: 12 additions & 0 deletions pcam/data/modelnet/modelnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Dataset: ModelNet

## Folder structure

Place the ModelNet dataset in this folder (`/path/to/pcam/data/modelnet/`), which should contain the following subfolders:
```
./modelnet40_ply_hdf5_2048/
./modelnet40_ply_hdf5_2048/ply_data_test0.h5
./modelnet40_ply_hdf5_2048/ply_data_test1.h5
./modelnet40_ply_hdf5_2048/ply_data_test_0_id2file.json
etc.
```
68 changes: 68 additions & 0 deletions pcam/datasets/collate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Part of the code in this file is taken from https://github.com/chrischoy/DeepGlobalRegistration/blob/46dd264580b4191accedc277f4ae434acdb4d380/dataloader/base_loader.py#L24

from pcam.tool.transforms import decompose_rotation_translation
import lightconvpoint.nn as lcp_nn
import torch
import numpy as np

class CollateFunc:
def __init__(self):
self.collation_fn = self.collate_pair_fn

def __call__(self, list_data):
return self.collation_fn(list_data)

def collate_pair_fn(self, list_data):
N = len(list_data)

list_data = [data for data in list_data if data is not None]
if N != len(list_data):
logging.info(f"Retain {len(list_data)} from {N} data.")
if len(list_data) == 0:
raise ValueError('No data in the batch')

xyz0_full, xyz1_full, xyz0, xyz1, trans, inv_trans, one_one_attention, filename, p0_mean, p1_mean = list(
zip(*list_data)
)

trans_batch = torch.from_numpy(np.stack(trans)).float()
inv_trans_batch = torch.from_numpy(np.stack(inv_trans)).float()

pts1 = torch.from_numpy(np.stack(xyz0)).float()
pts2 = torch.from_numpy(np.stack(xyz1)).float()
raw_pts1 = torch.from_numpy(np.stack(xyz0_full)).float()
raw_pts2 = torch.from_numpy(np.stack(xyz1_full)).float()

p0_mean = torch.from_numpy(np.stack(p0_mean)).float().transpose(1, 2)
p1_mean = torch.from_numpy(np.stack(p1_mean)).float().transpose(1, 2)

Rs, ts = decompose_rotation_translation(trans_batch)
Rs_inv, ts_inv = decompose_rotation_translation(inv_trans_batch)

ts = ts.unsqueeze(-1)
ts_inv = ts_inv.unsqueeze(-1)

search = lcp_nn.SearchQuantized(K=32, stride=1)
pts1 = pts1.transpose(1, 2)
pts2 = pts2.transpose(1, 2)
indices1, pts1 = search(pts1)
indices2, pts2 = search(pts2)

one_one_attention = torch.from_numpy(np.stack(one_one_attention)).float()

return {
"raw_src": raw_pts1,
"raw_tgt": raw_pts2,
"src": pts1,
"tgt": pts2,
"filename": filename,
"attention": one_one_attention,
"indices1": indices1,
"indices2": indices2,
"rotation": Rs,
"translation": ts,
"inv_rotation": Rs_inv,
"inv_translation": ts_inv,
"p0_mean": p0_mean,
"p1_mean": p1_mean,
}
Loading

0 comments on commit 1ef50d1

Please sign in to comment.