dtoolai.data

class dtoolai.data.ImageDataSet(uri, usetype='train')[source]

Class allowing a collection of images annotated with categories to be used as both a Pytorch Dataset and a dtool DataSet.

class dtoolai.data.TensorDataSet(uri)[source]

Class that allows numpy arrays to be accessed as both a pytorch Dataset and a dtool DataSet.

dim

The linear dimensions of the tensor, e.g. it is dim x dim in shape.

input_channels

The number of channels each tensor provides.

class dtoolai.data.WrappedDataSet(uri)[source]

Subclass of pytorch Dataset that provides dtool DataSet methods.

This class mostly provides methods that consumers of DataSets require, and passes those methods onto its internal DataSet object.

Parameters:uri – URI for enclosed dtool DataSet.
dtoolai.data.coerce_to_fixed_size_rgb(im, target_dim)[source]

Convert a PIL image to a fixed size and 3 channel RGB format.

dtoolai.data.create_tensor_dataset_from_arrays(output_base_uri, output_name, data_array, label_array, image_dim, readme_content)[source]

Create a dtool DataSet with the necessary annotations to be used as a TensorDataSet.

Parameters:
  • output_base_uri – The base URI where the dataset will be created.
  • output_name – The name for the output dataset.
  • data_array (ndarray) – The numpy array holding data.
  • label_array (ndarray) – The numpy array holding labels.
  • image_dim (tuple) – Dimensions to which input images should be reshaped.
  • readme_content (string) – Content that will be used to create README.yml in the created dataset.
Returns:

The URI of the created dataset

Return type:

URI

dtoolai.data.scaled_float_array_to_pil_image(array)[source]

Convert an array of floats to a PIL image.

Parameters:array (np.ndarray) – Array representing an image. Expected to be float and normalised between 0 and 1.
Returns:A PIL Image object created from the array