datasetinsights.datasets¶
- datasetinsights.datasets.dummy
- datasetinsights.datasets.unity_perception
- datasetinsights.datasets.unity_perception.captures
- datasetinsights.datasets.unity_perception.exceptions
- datasetinsights.datasets.unity_perception.metrics
- datasetinsights.datasets.unity_perception.references
- datasetinsights.datasets.unity_perception.tables
- datasetinsights.datasets.unity_perception.validation
datasetinsights.datasets.base¶
-
class
datasetinsights.datasets.base.
Dataset
¶ Bases:
object
Abstract base class for datasets.
-
static
create
(name, **kwargs)¶ Create a new instance of the dataset subclass
- Parameters
name (str) – unique identifier for a dataset subclass
config (dict) – parameters specific to each dataset subclass used to create a dataset instance
- Returns
an instance of the specified dataset subclass
-
static
find
(name)¶ Find Dataset subclass based on the given name
- Parameters
name (str) – unique identifier for a dataset subclass
- Returns
a label of the specified dataset subclass
-
static
datasetinsights.datasets.cityscapes¶
-
class
datasetinsights.datasets.cityscapes.
Cityscapes
(*, data_root='/data', split='train', transforms=None, **kwargs)¶ Bases:
datasetinsights.datasets.base.Dataset
- Parameters
data_root (str) – root directory prefix of all datasets
split (str) – indicate split type of the dataset (train|val|test)
-
root
¶ root directory of the dataset
- Type
str
-
split
¶ indicate split type of the dataset (train|val|test)
- Type
str
-
download
(cloud_path)¶ Download cityscapes dataset
Note
The current implementation assumes a GCS cloud path. Should we keep this method here if we want to support other cloud storage system?
- Parameters
cloud_path (str) – cloud path of the dataset
datasetinsights.datasets.coco¶
-
class
datasetinsights.datasets.coco.
CocoDetection
(*, data_root='/data', split='train', transforms=None, remove_examples_without_boxes=True, **kwargs)¶ Bases:
datasetinsights.datasets.base.Dataset
http://cocodataset.org/#detection-2019
-
download
(cloud_path='data/coco')¶
-
-
datasetinsights.datasets.coco.
convert_coco2canonical
(coco_annotation)¶ convert from a tuple of image and coco style dictionary describing the bboxes to a tuple of image, List of BBox2D :param coco_annotation: image and coco style dictionary :type coco_annotation: tuple
Returns: a tuple of image, List of BBox2D
datasetinsights.datasets.exceptions¶
-
exception
datasetinsights.datasets.exceptions.
DatasetNotFoundError
¶ Bases:
Exception
Raise when a dataset file can’t be found.
datasetinsights.datasets.groceries_real¶
-
class
datasetinsights.datasets.groceries_real.
GoogleGroceriesReal
(data_root, split='train', transforms=None)¶ Bases:
datasetinsights.datasets.base.Dataset
Google GroceriesReal Dataset
This dataset include groceries images and annotations in this paper. Please reach out to the authors to request the dataset.
The dataset should contain the following structures:
- Train Data/
file0.tfexample file1.tfexample …
- Eval Data/
file234.tfexample …
Label Map/label_map_with_path_64_retail.txt
-
root
¶ Local directory of the dataset is.
- Type
str
-
split
¶ Indicate split type of the dataset. Allowed value are (train|test).
- Type
str
-
transforms
¶ Callable transformation
-
label_mappings
¶ a dict of {label_id: label_name} mapping loaded from label_map_with_path_64_retail.txt
- Type
dict
-
GCS_PATH
= 'data/google_groceries'¶
-
LABEL_FILE
= 'Label Map/label_map_with_path_64_retail.txt'¶
-
LABEL_ZIP
= 'Label Map.zip'¶
-
LOCAL_PATH
= 'google_groceries'¶
-
SPLITS_FOLDER
= {'test': 'Eval Data', 'train': 'Train Data'}¶
-
SPLITS_ZIP
= {'test': 'Eval Data.zip', 'train': 'Train Data.zip'}¶
-
TF_FEATURES
= {'image/channels': FixedLenFeature(shape=[], dtype=tf.int64, default_value=None), 'image/encoded': FixedLenFeature(shape=[], dtype=tf.string, default_value=None), 'image/format': FixedLenFeature(shape=[], dtype=tf.string, default_value=None), 'image/height': FixedLenFeature(shape=[], dtype=tf.int64, default_value=None), 'image/object/bbox/occluded': FixedLenFeature(shape=[], dtype=tf.float32, default_value=None), 'image/object/bbox/xmax': VarLenFeature(dtype=tf.float32), 'image/object/bbox/xmin': VarLenFeature(dtype=tf.float32), 'image/object/bbox/ymax': VarLenFeature(dtype=tf.float32), 'image/object/bbox/ymin': VarLenFeature(dtype=tf.float32), 'image/object/class/label': VarLenFeature(dtype=tf.int64), 'image/object/class/text': VarLenFeature(dtype=tf.string), 'image/width': FixedLenFeature(shape=[], dtype=tf.int64, default_value=None)}¶
-
download
()¶ Download dataset from GCS
-
class
datasetinsights.datasets.groceries_real.
GroceriesReal
(*, data_path='/data', split='train', transforms=None, version='v3', **kwargs)¶ Bases:
datasetinsights.datasets.base.Dataset
Unity’s Groceries Real Dataset.
During the class instantiation, it would check whether the data is downloaded or not. If there is no dataset, it would raise an error. Please make sure you download the dataset before use this class.
The dataset contain the following structures:
images/
IMG_4185.JPG
IMG_4159.JPG
…
annotation_definition.json file stores label_id to label_name mappings
annotations.json file stores 2d bounding box records:
groceries_real_<split>.txt file which stores space deplimted list
of the indices in the annotations.json file, for a given data split.
-
dataset_directory
¶ Local directory where groceries_real dataset is saved.
- Type
str
-
split
¶ Indicate split type of the dataset. Allowed value are (train|val|test|test_high_ratio|test_low_ratio) test_high_ratio: Split of test dataset with high foreground-to-background ratio. test_low_ratio: Split of test dataset with low foreground-to-background ratio.
- Type
str
-
transforms
¶ Callable transformation
-
annotations
¶ A list of dict that contain image file path and 2D bounding box annotations.
- Type
list
-
split_indices
¶ A list of indices for this dataset split.
- Type
list
-
label_mappings
¶ a dict of {label_id: label_name} mapping
- Type
dict
-
version
¶ version of GroceriesReal dataset, e.g. “v3”.
- Type
str
-
default version="v3".
-
ANNOTATION_FILE
= 'annotations.json'¶
-
ARCHIVE_FILES
= {'v3': 'v3.zip'}¶
-
DEFINITION_FILE
= 'annotation_definitions.json'¶
-
SPLITS
= {'test': 'groceries_real_test.txt', 'test_high_contrast': 'groceries_real_test_high_contrast.txt', 'test_high_ratio': 'groceries_real_test_high_ratio.txt', 'test_low_contrast': 'groceries_real_test_low_contrast.txt', 'test_low_ratio': 'groceries_real_test_low_ratio.txt', 'train': 'groceries_real_train.txt', 'train_medium': 'groceries_real_train_medium.txt', 'train_small': 'groceries_real_train_small.txt', 'val': 'groceries_real_val.txt'}¶
-
SUBFOLDER
= 'groceries'¶
-
static
is_dataset_files_present
(data_path)¶
datasetinsights.datasets.kitti¶
-
class
datasetinsights.datasets.kitti.
Kitti
(root='/data/kitti', split='train', indices_file: str = None)¶ Bases:
datasetinsights.datasets.base.Dataset
dataloader for kitti dataset http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d
-
download
(cloud_path='data/kitti')¶
-
download_kitti_zips
(cloud_client, cloud_path='data/kitti')¶
-
-
class
datasetinsights.datasets.kitti.
KittiBox3d
(*, label: str, position, dimensions, angle, sample_idx, score: float = 1.0)¶ Bases:
object
class to represent a bounding box for the kitti dataset. Note that this style of bounding box is not primarily supported. The canonical 3d bounding box class for this repo is the class BBox3D. Reference code for KittiBox3d found at http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d https://github.com/bostondiditeam/kitti/tree/master/resources/devkit_object To convert from kitti style to nuscenes use the method convert_kitti2nu.
-
class
datasetinsights.datasets.kitti.
KittiTransforms
(calib_filename)¶ Bases:
object
Class to hold transformation matrices for a kitti data sample see more at https://github.com/yanii/kitti-pcl/blob/master/KITTI_README.TXT
-
property
projection_mat_left
¶ Projection matrix for left image (to project bounding box coordinate to image coordinates).
- Type
Returns
-
property
projection_rect_combined
¶ Merge rectification and projection into one matrix.
Returns: combined rectification and projection matrix
-
property
r0_rect
¶ Quaternion to rectify camera frame.
- Type
Returns
-
property
velo_to_cam_rotation
¶ - Rotation matrix takes a point in Velodyne coordinates and transforms it
into the
coordinate system of the left video camera. Likewise it serves as a representation of the Velodyne coordinate frame in camera coordinates. Returns: Rotation matrix
-
property
velo_to_cam_translation
¶ - Translation matrix takes a point in Velodyne coordinates and transforms
it into the
coordinate system of the left video camera. Likewise it serves as a representation of the Velodyne coordinate frame in camera coordinates. Returns: Translation matrix
-
property
-
datasetinsights.datasets.kitti.
convert_kitti2nu
(*, bbox: datasetinsights.datasets.kitti.KittiBox3d, transforms: datasetinsights.datasets.kitti.KittiTransforms) → datasetinsights.io.bbox.BBox3D¶ convert a bounding box from kitti format to nuscenes format
- Parameters
bbox – bounding box in kitti format
transforms – camera transforms
Returns:
-
datasetinsights.datasets.kitti.
read_kitti_calib
(filename)¶ Read the camera 2 calibration matrix from box text file
-
datasetinsights.datasets.kitti.
read_kitti_objects
(filename)¶
datasetinsights.datasets.nuscenes¶
-
class
datasetinsights.datasets.nuscenes.
NuscenesDataLoader
(*, data_root='/data', split='train', version='v1.0', full_dataset: bool = False, download=False, sensor_data: List[str] = ['CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_BACK_RIGHT', 'CAM_BACK', 'CAM_BACK_LEFT', 'CAM_FRONT_LEFT', 'RADAR_FRONT', 'RADAR_FRONT_LEFT', 'RADAR_FRONT_RIGHT', 'RADAR_BACK_LEFT', 'RADAR_BACK_RIGHT', 'LIDAR_TOP'], coordinates='global')¶ Bases:
torch.utils.data.dataset.Dataset
Nuscenes Dataset https://www.nuscenes.org/ :param data_root: root directory prefix of all datasets :type data_root: str :param split: test or valuation. see SPLITS constant for possible values :param version: numerical version of nuscenes dataset. :param sensor_data: what sensor data to use, can be any of the strings in :param SENSOR_DATA_KEYS: :param full_dataset: whether to use the full dataset. If false, use the mini :param dataset: :param download: whether or no to download the nuscenes dataset from gcs. If :param false: :param it is assumed the: :param dataset is stored at the location specified by root: :param coordinates: whether to use coordinates in the local coordinate system :param of the sensor or the global: :param log coordinates. Options: ‘sensor’ or ‘global’
-
root
¶ directory where nuscenes data is stored. If no value is provided, the specified version of nuscenes is downloaded.
-
download
(version='v1.0-mini')¶ download the nuscenes dataset version specified to /data/sets/nuscenes
-
datasetinsights.datasets.nyudepth¶
Load NYU Depth V2 data.
- Downloaded NYUDepth dataset link:
https://drive.google.com/drive/folders/1TzwfNA5JRFTPO-kHMU___kILmOEodoBo
This dataset is not the official NYU Depth V2 datset. The data are preprocessed. For more information, see the link below:
-
class
datasetinsights.datasets.nyudepth.
NyuDepth
(data_root='/data', transforms=None, split='train', cloud_path='data/nyudepth')¶ Bases:
datasetinsights.datasets.base.Dataset
-
root
¶ local directory where nyu_v2 dataset is saved
- Type
str
-
nyu2_data
¶ training or testing data
- Type
Pandas DataFrame
-
split
¶ test or valuation. see SPLITS constant for possible values
- Type
str
-
datasetinsights.datasets.synthetic¶
Simulation Dataset Catalog
-
class
datasetinsights.datasets.synthetic.
SynDetection2D
(*, data_path=None, split='all', transforms=None, version='0.0.1', def_id=4, train_split_ratio=0.9, random_seed=47, **kwargs)¶ Bases:
datasetinsights.datasets.base.Dataset
Synthetic dataset for 2D object detection.
During the class instantiation, it would check whether the data files such as annotations.json, images.png are present, if not it’ll check whether a compressed dataset file is present which contains the necessary files, if not it’ll raise an error.
See synthetic dataset schema documentation for more details. <https://datasetinsights.readthedocs.io/en/latest/Synthetic_Dataset_Schema.html>
-
catalog
¶ catalog of all captures in this dataset
- Type
list
-
transforms
¶ callable transformation that applies to a pair of capture, annotation. Capture is the information captured by the sensor, in this case an image, and annotations, which in this dataset are 2d bounding box coordinates and labels.
-
split
¶ indicate split type of the dataset (train|val|test)
- Type
str
-
label_mappings
¶ a dict of {label_id: label_name} mapping
- Type
dict
-
ARCHIVE_FILE
= 'SynthDet.zip'¶
-
SUBFOLDER
= 'synthetic'¶
-
static
is_dataset_files_present
(data_path)¶
-
-
datasetinsights.datasets.synthetic.
read_bounding_box_2d
(annotation, label_mappings=None)¶ Convert dictionary representations of 2d bounding boxes into objects of the BBox2D class
- Parameters
annotation (List[dict]) – 2D bounding box annotation
label_mappings (dict) – a dict of {label_id: label_name} mapping
- Returns
A list of 2D bounding box objects
-
datasetinsights.datasets.synthetic.
read_bounding_box_3d
(annotation, label_mappings=None)¶ Convert dictionary representations of 3d bounding boxes into objects of the BBox3d class
- Parameters
annotation (List[dict]) – 3D bounding box annotation
label_mappings (dict) – a dict of {label_id: label_name} mapping
- Returns
A list of 3d bounding box objects
-
class
datasetinsights.datasets.
Cityscapes
(*, data_root='/data', split='train', transforms=None, **kwargs)¶ Bases:
datasetinsights.datasets.base.Dataset
- Parameters
data_root (str) – root directory prefix of all datasets
split (str) – indicate split type of the dataset (train|val|test)
-
root
¶ root directory of the dataset
- Type
str
-
split
¶ indicate split type of the dataset (train|val|test)
- Type
str
-
download
(cloud_path)¶ Download cityscapes dataset
Note
The current implementation assumes a GCS cloud path. Should we keep this method here if we want to support other cloud storage system?
- Parameters
cloud_path (str) – cloud path of the dataset
-
class
datasetinsights.datasets.
CocoDetection
(*, data_root='/data', split='train', transforms=None, remove_examples_without_boxes=True, **kwargs)¶ Bases:
datasetinsights.datasets.base.Dataset
http://cocodataset.org/#detection-2019
-
download
(cloud_path='data/coco')¶
-
-
class
datasetinsights.datasets.
Dataset
¶ Bases:
object
Abstract base class for datasets.
-
static
create
(name, **kwargs)¶ Create a new instance of the dataset subclass
- Parameters
name (str) – unique identifier for a dataset subclass
config (dict) – parameters specific to each dataset subclass used to create a dataset instance
- Returns
an instance of the specified dataset subclass
-
static
find
(name)¶ Find Dataset subclass based on the given name
- Parameters
name (str) – unique identifier for a dataset subclass
- Returns
a label of the specified dataset subclass
-
static
-
class
datasetinsights.datasets.
GoogleGroceriesReal
(data_root, split='train', transforms=None)¶ Bases:
datasetinsights.datasets.base.Dataset
Google GroceriesReal Dataset
This dataset include groceries images and annotations in this paper. Please reach out to the authors to request the dataset.
The dataset should contain the following structures:
- Train Data/
file0.tfexample file1.tfexample …
- Eval Data/
file234.tfexample …
Label Map/label_map_with_path_64_retail.txt
-
root
¶ Local directory of the dataset is.
- Type
str
-
split
¶ Indicate split type of the dataset. Allowed value are (train|test).
- Type
str
-
transforms
¶ Callable transformation
-
label_mappings
¶ a dict of {label_id: label_name} mapping loaded from label_map_with_path_64_retail.txt
- Type
dict
-
GCS_PATH
= 'data/google_groceries'¶
-
LABEL_FILE
= 'Label Map/label_map_with_path_64_retail.txt'¶
-
LABEL_ZIP
= 'Label Map.zip'¶
-
LOCAL_PATH
= 'google_groceries'¶
-
SPLITS_FOLDER
= {'test': 'Eval Data', 'train': 'Train Data'}¶
-
SPLITS_ZIP
= {'test': 'Eval Data.zip', 'train': 'Train Data.zip'}¶
-
TF_FEATURES
= {'image/channels': FixedLenFeature(shape=[], dtype=tf.int64, default_value=None), 'image/encoded': FixedLenFeature(shape=[], dtype=tf.string, default_value=None), 'image/format': FixedLenFeature(shape=[], dtype=tf.string, default_value=None), 'image/height': FixedLenFeature(shape=[], dtype=tf.int64, default_value=None), 'image/object/bbox/occluded': FixedLenFeature(shape=[], dtype=tf.float32, default_value=None), 'image/object/bbox/xmax': VarLenFeature(dtype=tf.float32), 'image/object/bbox/xmin': VarLenFeature(dtype=tf.float32), 'image/object/bbox/ymax': VarLenFeature(dtype=tf.float32), 'image/object/bbox/ymin': VarLenFeature(dtype=tf.float32), 'image/object/class/label': VarLenFeature(dtype=tf.int64), 'image/object/class/text': VarLenFeature(dtype=tf.string), 'image/width': FixedLenFeature(shape=[], dtype=tf.int64, default_value=None)}¶
-
download
()¶ Download dataset from GCS
-
class
datasetinsights.datasets.
GroceriesReal
(*, data_path='/data', split='train', transforms=None, version='v3', **kwargs)¶ Bases:
datasetinsights.datasets.base.Dataset
Unity’s Groceries Real Dataset.
During the class instantiation, it would check whether the data is downloaded or not. If there is no dataset, it would raise an error. Please make sure you download the dataset before use this class.
The dataset contain the following structures:
images/
IMG_4185.JPG
IMG_4159.JPG
…
annotation_definition.json file stores label_id to label_name mappings
annotations.json file stores 2d bounding box records:
groceries_real_<split>.txt file which stores space deplimted list
of the indices in the annotations.json file, for a given data split.
-
dataset_directory
¶ Local directory where groceries_real dataset is saved.
- Type
str
-
split
¶ Indicate split type of the dataset. Allowed value are (train|val|test|test_high_ratio|test_low_ratio) test_high_ratio: Split of test dataset with high foreground-to-background ratio. test_low_ratio: Split of test dataset with low foreground-to-background ratio.
- Type
str
-
transforms
¶ Callable transformation
-
annotations
¶ A list of dict that contain image file path and 2D bounding box annotations.
- Type
list
-
split_indices
¶ A list of indices for this dataset split.
- Type
list
-
label_mappings
¶ a dict of {label_id: label_name} mapping
- Type
dict
-
version
¶ version of GroceriesReal dataset, e.g. “v3”.
- Type
str
-
default version="v3".
-
ANNOTATION_FILE
= 'annotations.json'¶
-
ARCHIVE_FILES
= {'v3': 'v3.zip'}¶
-
DEFINITION_FILE
= 'annotation_definitions.json'¶
-
SPLITS
= {'test': 'groceries_real_test.txt', 'test_high_contrast': 'groceries_real_test_high_contrast.txt', 'test_high_ratio': 'groceries_real_test_high_ratio.txt', 'test_low_contrast': 'groceries_real_test_low_contrast.txt', 'test_low_ratio': 'groceries_real_test_low_ratio.txt', 'train': 'groceries_real_train.txt', 'train_medium': 'groceries_real_train_medium.txt', 'train_small': 'groceries_real_train_small.txt', 'val': 'groceries_real_val.txt'}¶
-
SUBFOLDER
= 'groceries'¶
-
static
is_dataset_files_present
(data_path)¶
-
class
datasetinsights.datasets.
NyuDepth
(data_root='/data', transforms=None, split='train', cloud_path='data/nyudepth')¶ Bases:
datasetinsights.datasets.base.Dataset
-
root
¶ local directory where nyu_v2 dataset is saved
- Type
str
-
nyu2_data
¶ training or testing data
- Type
Pandas DataFrame
-
split
¶ test or valuation. see SPLITS constant for possible values
- Type
str
-
-
class
datasetinsights.datasets.
SynDetection2D
(*, data_path=None, split='all', transforms=None, version='0.0.1', def_id=4, train_split_ratio=0.9, random_seed=47, **kwargs)¶ Bases:
datasetinsights.datasets.base.Dataset
Synthetic dataset for 2D object detection.
During the class instantiation, it would check whether the data files such as annotations.json, images.png are present, if not it’ll check whether a compressed dataset file is present which contains the necessary files, if not it’ll raise an error.
See synthetic dataset schema documentation for more details. <https://datasetinsights.readthedocs.io/en/latest/Synthetic_Dataset_Schema.html>
-
catalog
¶ catalog of all captures in this dataset
- Type
list
-
transforms
¶ callable transformation that applies to a pair of capture, annotation. Capture is the information captured by the sensor, in this case an image, and annotations, which in this dataset are 2d bounding box coordinates and labels.
-
split
¶ indicate split type of the dataset (train|val|test)
- Type
str
-
label_mappings
¶ a dict of {label_id: label_name} mapping
- Type
dict
-
ARCHIVE_FILE
= 'SynthDet.zip'¶
-
SUBFOLDER
= 'synthetic'¶
-
static
is_dataset_files_present
(data_path)¶
-