Skip to content

Commit

Permalink
Synthia data loader fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischoy committed Jan 27, 2020
1 parent 8bf3f39 commit 4a4c0c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
13 changes: 0 additions & 13 deletions lib/datasets/stanford.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,6 @@ class StanfordArea5Dataset(StanfordDataset):
}


class StanfordArea53cmDataset(StanfordArea5Dataset):
CLIP_BOUND = 3.2
VOXEL_SIZE = 0.03


class StanfordArea57d5cmDataset(StanfordArea5Dataset):
VOXEL_SIZE = 0.075


class StanfordArea510cmDataset(StanfordArea5Dataset):
VOXEL_SIZE = 0.1


def test(config):
"""Test point cloud data loader.
"""
Expand Down
12 changes: 10 additions & 2 deletions lib/datasets/synthia.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np

from collections import defaultdict
from plyfile import PlyData

from lib.pc_utils import Camera, read_plyfile
from lib.dataset import DictDataset, VoxelizationDataset, TemporalVoxelizationDataset, \
Expand Down Expand Up @@ -111,8 +112,6 @@ class SynthiaVoxelizationDataset(VoxelizationDataset):
VOXEL_SIZE = 15 # cm

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

# Augmentation arguments
ROTATION_AUGMENTATION_BOUND = ((0, 0), (-np.pi, np.pi), (0, 0))
Expand Down Expand Up @@ -158,6 +157,15 @@ def __init__(self,
elastic_distortion=elastic_distortion,
config=config)

def load_ply(self, index):
filepath = self.data_root / self.data_paths[index]
plydata = PlyData.read(filepath)
data = plydata.elements[0].data
coords = np.array([data['x'], data['y'], data['z']], dtype=np.float32).T
feats = np.array([data['r'], data['g'], data['b']], dtype=np.float32).T
labels = np.array(data['l'], dtype=np.int32)
return coords, feats, labels, None


class SynthiaTemporalVoxelizationDataset(TemporalVoxelizationDataset):

Expand Down
4 changes: 2 additions & 2 deletions models/conditional_random_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ def forward(self, x):
# Pairwise potential
out = self.convs[i].apply(out, self.conv.kernel, x.pixel_dist, self.conv.stride,
self.conv.kernel_size, self.conv.dilation, self.region_type_,
self.region_offset_, x.coords_key, x.coords_key, x.C)
self.region_offset_, x.coords_key, x.coords_key, x.coords_man)
# Add unary
out += xf

if self.requires_mapping:
# Map the CRF output to the origianl space
out = SparseMM()(Variable(self.out_mapping), out)

return SparseTensor(out, coords_key=x.coords_key, coords_manager=x.C)
return SparseTensor(out, coords_key=x.coords_key, coords_manager=x.coords_man)


class BilateralCRF(Wrapper):
Expand Down

0 comments on commit 4a4c0c5

Please sign in to comment.