kaolin.io.dataset

API

class kaolin.io.dataset.Cache(func, cache_dir, cache_key)

Bases: object

Caches the results of a function to disk. If already cached, data is returned from disk. Otherwise, the function is executed. Output tensors are always on CPU device.

Parameters
  • func (Callable) – The function to cache.

  • cache_dir (str or Path) – Directory where objects will be cached.

  • cache_key (str) – The corresponding cache key for this function.

try_get(unique_id: str)

Read cache from disk. If not found, raise error.

Parameters

unique_id (str) – The unique id with which to name the cached file.

Returns

Results from self.func if exists on disk.

class kaolin.io.dataset.CombinationDataset(datasets)

Bases: Generic[torch.utils.data.dataset.T_co]

Dataset combining a list of datasets into a unified dataset object.

Useful when multiple output representations are needed from a common base representation (Eg. when a mesh is to be served as both a pointcloud and a voxelgrid, etc.)

The output of get_attributes will be a tuple of all the get_attributes of the dataset list.

The output of get_data will be a tuple of all the get_data of the dataset list.

If a dataset does not have get_data, __getitem__ will be used instead.

The output of get_cache_key will be the cache key of the first dataset. If that dataset does not provide get_cache_key, the index will be used instead.

Parameters

datasets – list or tuple of datasets

get_attributes(index)

Returns the attributes at the given index. Attributes are usually not transformed by wrappers such as ProcessedDataset.

get_cache_key(index)
get_data(index)

Returns the data at the given index.

class kaolin.io.dataset.KaolinDataset(*args, **kwds)

Bases: Generic[torch.utils.data.dataset.T_co]

A dataset supporting the separation of data and attributes, and combines them in its __getitem__. The return value of __getitem__ will be a named tuple containing the return value of both get_data and get_attributes. The difference between get_data and get_attributes is that data are able to be transformed or preprocessed (such as using ProcessedDataset), while attributes are generally not.

abstract get_attributes(index)

Returns the attributes at the given index. Attributes are usually not transformed by wrappers such as ProcessedDataset.

abstract get_data(index)

Returns the data at the given index.

class kaolin.io.dataset.KaolinDatasetItem(data, attributes)

Bases: tuple

property attributes

Alias for field number 1

property data

Alias for field number 0

class kaolin.io.dataset.ProcessedDataset(dataset, preprocessing_transform=None, cache_dir=None, num_workers=None, transform=None, no_progress: bool = False)

Bases: Generic[torch.utils.data.dataset.T_co]

get_attributes(index)

Returns the attributes at the given index. Attributes are usually not transformed by wrappers such as ProcessedDataset.

get_cache_key(index)
get_data(index)

Returns the data at the given index.