Skip to content

Commit

Permalink
Synthia training
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischoy committed Nov 3, 2019
1 parent 26a90b5 commit d723996
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 16 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Modify the `BATCH_SIZE` accordingly.
The first argument is the GPU id and the second argument is the path postfix
and the last argument is the miscellaneous arguments.

The official evaluation metric for ScanNet is mIoU. OA, Overal Accuracy is not the official metric and is a lot easier and should not be used soley for any official papers without mIoU for fair comparison.
The official evaluation metric for ScanNet is mIoU. OA, Overal Accuracy is not the official metric similar to the 2D image semantic segmentation as it is a lot easier and doesn't reflect the quality of the semantic segmentation. This is due to the fact that most of the scenes consist of large structures such as walls, floors and these will dominate the statistics. Thus, overall accuracy should not be used solely to prevent reviewers from comparing the baselines fairly.

## Synthia 4D Experiment

Expand All @@ -36,10 +36,23 @@ The official evaluation metric for ScanNet is mIoU. OA, Overal Accuracy is not t
2. Extract

```
cd /path/to/extract/synthia4d
wget http://cvgl.stanford.edu/data2/Synthia4D.tar
tar -xf Synthia4D.tar
tar -xzf *.tar.bz2
tar -xvjf *.tar.bz2
```

3. Training

```
export BATCH_SIZE=N; \
./scripts/train_synthia4d.sh 0 \
"-default" \
"--synthia_path /path/to/extract/synthia4d"
```

The above script trains a network. You have to change the arguments accordingly. The first argument to the script is the GPU id. Second argument is the log directory postfix; change to mark your experimental setup. The final argument is a series of the miscellaneous aruments. You have to specify the synthia directory here. Also, you have to wrap all arguments with " ".


## Model Zoo

Expand Down
3 changes: 2 additions & 1 deletion lib/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def __getitem__(self, index):
pointcloud = pointcloud[inds]

# Prevoxel transformations
pointcloud = self.prevoxel_transform(pointcloud)
if self.prevoxel_transform is not None:
pointcloud = self.prevoxel_transform(pointcloud)

coords, feats, labels = self.convert_mat2cfl(pointcloud)
coords, feats, labels, transformation = self.voxelizer.voxelize(
Expand Down
6 changes: 4 additions & 2 deletions lib/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from .synthia import SynthiaVoxelizationDataset, SynthiaTemporalVoxelizationDataset
from .synthia import SynthiaCVPR15cmVoxelizationDataset, SynthiaCVPR30cmVoxelizationDataset, \
SynthiaAllSequencesVoxelizationDataset
from .stanford import StanfordVoxelizationDataset, StanfordVoxelization2cmDataset
from .scannet import ScannetVoxelizationDataset, ScannetVoxelization2cmDataset

DATASETS = [
StanfordVoxelizationDataset, StanfordVoxelization2cmDataset, ScannetVoxelizationDataset,
ScannetVoxelization2cmDataset, SynthiaVoxelizationDataset, SynthiaTemporalVoxelizationDataset
ScannetVoxelization2cmDataset, SynthiaCVPR15cmVoxelizationDataset,
SynthiaCVPR30cmVoxelizationDataset, SynthiaAllSequencesVoxelizationDataset
]


Expand Down
2 changes: 1 addition & 1 deletion lib/datasets/scannet.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self,
data_root = config.scannet_path
if phase not in [DatasetPhase.Train, DatasetPhase.TrainVal]:
self.CLIP_BOUND = self.TEST_CLIP_BOUND
data_paths = read_txt(os.path.join(data_root, self.DATA_PATH_FILE[phase]))
data_paths = read_txt(os.path.join('./splits/scannt', self.DATA_PATH_FILE[phase]))
logging.info('Loading {}: {}'.format(self.__class__.__name__, self.DATA_PATH_FILE[phase]))
super().__init__(
data_paths,
Expand Down
37 changes: 27 additions & 10 deletions lib/datasets/synthia.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ class SynthiaVoxelizationDataset(VoxelizationDataset):
# Voxelization arguments
CLIP_BOUND = ((-1800, 1800), (-1800, 1800), (-1800, 1800))
TEST_CLIP_BOUND = ((-2500, 2500), (-2500, 2500), (-2500, 2500))
VOXEL_SIZE = 30 # cm
VOXEL_SIZE = 15 # cm

PREVOXELIZE_VOXEL_SIZE = 7.5
# Elastic distortion, (granularity, magitude) pairs
PREVOXELIZE_VOXEL_SIZE = 30
ELASTIC_DISTORT_PARAMS = ((80, 300),)

# Augmentation arguments
Expand All @@ -124,10 +125,9 @@ class SynthiaVoxelizationDataset(VoxelizationDataset):

# Split used in the Minkowski ConvNet, CVPR'19
DATA_PATH_FILE = {
DatasetPhase.Train: 'train_raw_difficult.txt',
DatasetPhase.Val: 'val_raw_difficult.txt',
DatasetPhase.TrainVal: 'trainval_raw_difficult.txt',
DatasetPhase.Test: 'test_raw_difficult.txt'
DatasetPhase.Train: 'train_cvpr19.txt',
DatasetPhase.Val: 'val_cvpr19.txt',
DatasetPhase.Test: 'test_cvpr19.txt'
}

def __init__(self,
Expand All @@ -144,7 +144,7 @@ def __init__(self,
if phase not in [DatasetPhase.Train, DatasetPhase.TrainVal]:
self.CLIP_BOUND = self.TEST_CLIP_BOUND
data_root = config.synthia_path
data_paths = read_txt(osp.join(data_root, self.DATA_PATH_FILE[phase]))
data_paths = read_txt(osp.join('./splits/synthia4d', self.DATA_PATH_FILE[phase]))
data_paths = [d.split()[0] for d in data_paths]
logging.info('Loading {}: {}'.format(self.__class__.__name__, self.DATA_PATH_FILE[phase]))
super().__init__(
Expand All @@ -164,10 +164,11 @@ class SynthiaTemporalVoxelizationDataset(TemporalVoxelizationDataset):
# Voxelization arguments
CLIP_BOUND = ((-1800, 1800), (-1800, 1800), (-1800, 1800))
TEST_CLIP_BOUND = ((-2500, 2500), (-2500, 2500), (-2500, 2500))
VOXEL_SIZE = 30 # cm
VOXEL_SIZE = 15 # cm

PREVOXELIZE_VOXEL_SIZE = 30
ELASTIC_DISTORT_PARAMS = ((80, 300),)
PREVOXELIZE_VOXEL_SIZE = 7.5
# For temporal sequences, the voxel locations has to be aligned exactly.
ELASTIC_DISTORT_PARAMS = None

# Augmentation arguments
ROTATION_AUGMENTATION_BOUND = ((0, 0), (-np.pi, np.pi), (0, 0))
Expand Down Expand Up @@ -250,6 +251,22 @@ def _transform(xyz, intrinsic, extrinsic):
return ptc, center


class SynthiaCVPR15cmVoxelizationDataset(SynthiaVoxelizationDataset):
pass


class SynthiaCVPR30cmVoxelizationDataset(SynthiaVoxelizationDataset):
VOXEL_SIZE = 30


class SynthiaAllSequencesVoxelizationDataset(SynthiaVoxelizationDataset):
DATA_PATH_FILE = {
DatasetPhase.Train: 'train_raw.txt',
DatasetPhase.Val: 'val_raw.txt',
DatasetPhase.Test: 'test_raw.txt'
}


class TestSynthia(unittest.TestCase):

@debug_on()
Expand Down

0 comments on commit d723996

Please sign in to comment.