Commit 90396ed6 authored by liyinhao's avatar liyinhao
Browse files

change docstring

parent d9f21dc9
import os.path as osp
import mmcv
import numpy as np
from mmdet.datasets.registry import PIPELINES
@PIPELINES.register_module
class LoadPointsFromFile(object):
def __init__(self, points_dim=4, with_reflectivity=True):
self.points_dim = points_dim
self.with_reflectivity = with_reflectivity
def __call__(self, results):
if results['pts_prefix'] is not None:
filename = osp.join(results['pts_prefix'],
results['img_info']['filename'])
else:
filename = results['img_info']['filename']
points = np.fromfile(
filename, dtype=np.float32).reshape(-1, self.points_dim)
results['points'] = points
return results
def __repr__(self):
repr_str = self.__class__.__name__
repr_str += '(points_dim={})'.format(self.points_dim)
repr_str += '(points_dim={})'.format(self.with_reflectivity)
return repr_str
@PIPELINES.register_module
class LoadMultiViewImageFromFiles(object):
""" Load multi channel images from a list of separate channel files.
Expects results['filename'] to be a list of filenames
"""
def __init__(self, to_float32=False, color_type='unchanged'):
self.to_float32 = to_float32
self.color_type = color_type
def __call__(self, results):
if results['img_prefix'] is not None:
filename = [
osp.join(results['img_prefix'], fname)
for fname in results['img_info']['filename']
]
else:
filename = results['img_info']['filename']
img = np.stack(
[mmcv.imread(name, self.color_type) for name in filename], axis=-1)
if self.to_float32:
img = img.astype(np.float32)
results['filename'] = filename
results['img'] = img
results['img_shape'] = img.shape
results['ori_shape'] = img.shape
# Set initial values for default meta_keys
results['pad_shape'] = img.shape
results['scale_factor'] = 1.0
num_channels = 1 if len(img.shape) < 3 else img.shape[2]
results['img_norm_cfg'] = dict(
mean=np.zeros(num_channels, dtype=np.float32),
std=np.ones(num_channels, dtype=np.float32),
to_rgb=False)
return results
def __repr__(self):
return "{} (to_float32={}, color_type='{}')".format(
self.__class__.__name__, self.to_float32, self.color_type)
...@@ -9,8 +9,7 @@ def create_indoor_info_file(data_path, ...@@ -9,8 +9,7 @@ def create_indoor_info_file(data_path,
pkl_prefix='sunrgbd', pkl_prefix='sunrgbd',
save_path=None, save_path=None,
use_v1=False): use_v1=False):
""" """Create indoor information file.
Create indoor information file.
Get information of the raw data and save it to the pkl file. Get information of the raw data and save it to the pkl file.
...@@ -19,10 +18,6 @@ def create_indoor_info_file(data_path, ...@@ -19,10 +18,6 @@ def create_indoor_info_file(data_path,
pkl_prefix (str): Prefix of the pkl to be saved. Default: 'sunrgbd'. pkl_prefix (str): Prefix of the pkl to be saved. Default: 'sunrgbd'.
save_path (str): Path of the pkl to be saved. Default: None. save_path (str): Path of the pkl to be saved. Default: None.
use_v1 (bool): Whether to use v1. Default: False. use_v1 (bool): Whether to use v1. Default: False.
Returns:
None
""" """
assert os.path.exists(data_path) assert os.path.exists(data_path)
assert pkl_prefix in ['sunrgbd', 'scannet'] assert pkl_prefix in ['sunrgbd', 'scannet']
......
...@@ -5,8 +5,7 @@ import numpy as np ...@@ -5,8 +5,7 @@ import numpy as np
class ScanNetData(object): class ScanNetData(object):
""" """ScanNet Data
ScanNet Data
Generate scannet infos for scannet_converter Generate scannet infos for scannet_converter
...@@ -49,8 +48,7 @@ class ScanNetData(object): ...@@ -49,8 +48,7 @@ class ScanNetData(object):
return np.load(box_file) return np.load(box_file)
def get_infos(self, num_workers=4, has_label=True, sample_id_list=None): def get_infos(self, num_workers=4, has_label=True, sample_id_list=None):
""" """Get data infos.
Get data infos.
This method gets information from the raw data. This method gets information from the raw data.
......
...@@ -7,8 +7,7 @@ import scipy.io as sio ...@@ -7,8 +7,7 @@ import scipy.io as sio
def random_sampling(pc, num_samples, replace=None, return_choices=False): def random_sampling(pc, num_samples, replace=None, return_choices=False):
""" """Random Sampling.
Random Sampling.
Sampling point cloud to num_samples points. Sampling point cloud to num_samples points.
...@@ -58,8 +57,7 @@ class SUNRGBDInstance(object): ...@@ -58,8 +57,7 @@ class SUNRGBDInstance(object):
class SUNRGBDData(object): class SUNRGBDData(object):
""" """SUNRGBD Data
SUNRGBD Data
Generate scannet infos for sunrgbd_converter Generate scannet infos for sunrgbd_converter
...@@ -127,8 +125,7 @@ class SUNRGBDData(object): ...@@ -127,8 +125,7 @@ class SUNRGBDData(object):
return objects return objects
def get_infos(self, num_workers=4, has_label=True, sample_id_list=None): def get_infos(self, num_workers=4, has_label=True, sample_id_list=None):
""" """Get data infos.
Get data infos.
This method gets information from the raw data. This method gets information from the raw data.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment