ClassificationData#

class ClassificationData[source]#

The ClassificationData class is used to load and preprocess data for a classification task.

It is a subclass of the VisionData class. The ClassificationData class is containing additional data and general methods intended for easily accessing metadata relevant for validating a computer vision classification ML models.

__init__(data_loader: DataLoader, num_classes: Optional[int] = None, label_map: Optional[Dict[int, str]] = None, transform_field: Optional[str] = 'transforms')[source]#
__new__(*args, **kwargs)#

Attributes

ClassificationData.classes_indices

Return dict of classes as keys, and list of corresponding indices (in Dataset) of samples that include this class (in the label).

ClassificationData.data_dimension

Return how many dimensions the image data have.

ClassificationData.data_loader

Return the data loader.

ClassificationData.has_images

Return True if the data loader has images.

ClassificationData.has_labels

Return True if the data loader has labels.

ClassificationData.n_of_samples_per_class

Return a dictionary containing the number of samples per class.

ClassificationData.num_classes

Return the number of classes in the dataset.

ClassificationData.num_samples

Return the number of samples in the dataset.

ClassificationData.original_num_samples

Return the number of samples in the original dataset.

ClassificationData.task_type

Return the task type (classification).

ClassificationData.transform_field

Return the data loader.

Methods

ClassificationData.assert_images_valid()

Assert the image formatter defined is valid.

ClassificationData.assert_labels_valid()

Assert the label formatter defined is valid.

ClassificationData.batch_of_index(*indices)

Return batch samples of the given batch indices.

ClassificationData.batch_to_images(batch)

Transform a batch of data to images in the accpeted format.

ClassificationData.batch_to_labels(batch)

Extract the labels from a batch of data.

ClassificationData.copy([n_samples, ...])

Create new copy of this object, with the data-loader and dataset also copied, and altered by the given parameters.

ClassificationData.from_dataset(data[, ...])

Create VisionData instance from a Dataset instance.

ClassificationData.get_augmented_dataset(aug)

Return a copy of the vision data object with the augmentation in the start of it.

ClassificationData.get_classes(batch_labels)

Get a labels batch and return classes inside it.

ClassificationData.get_transform_type()

Return transforms handler created from the transform field.

ClassificationData.infer_on_batch(batch, ...)

Return the predictions of the model on a batch of data.

ClassificationData.init_cache()

Initialize the cache of the classes' metadata info.

ClassificationData.is_sampled()

Return whether the vision data is running on sample of the data.

ClassificationData.label_id_to_name(class_id)

Return the name of the class with the given id.

ClassificationData.to_batch(*samples)

Use the defined collate_fn to transform a few data items to batch format.

ClassificationData.to_dataset_index(...)

Return for the given batch_index the sample index in the dataset object.

ClassificationData.update_cache(batch)

Get labels and update the classes' metadata info.

ClassificationData.validate_format(model[, ...])

Validate the correctness of the data class implementation according to the expected format.

ClassificationData.validate_get_classes(batch)

Validate that the get_classes function returns data in the correct format.

ClassificationData.validate_image_data(batch)

Validate that the data is in the required format.

ClassificationData.validate_label(batch)

Validate the label.

ClassificationData.validate_prediction(...)

Validate the prediction.

ClassificationData.validate_shared_label(other)

Verify presence of shared labels.